Skip to content

Add more examples for pyiceberg view#3414

Open
MonkeyCanCode wants to merge 1 commit into
apache:mainfrom
MonkeyCanCode:pyiceberg_view_doc
Open

Add more examples for pyiceberg view#3414
MonkeyCanCode wants to merge 1 commit into
apache:mainfrom
MonkeyCanCode:pyiceberg_view_doc

Conversation

@MonkeyCanCode
Copy link
Copy Markdown

Closes #3413

Rationale for this change

Adds more examples around view support.

Are these changes tested?

Yes. Those had been tested locally with local Polaris.

Are there any user-facing changes?

No.

Copy link
Copy Markdown
Contributor

@gabeiglio gabeiglio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! left some small comments but overall looks good

Comment thread mkdocs/docs/api.md
from pyiceberg.catalog import load_catalog
from pyiceberg.view import SQLViewRepresentation, ViewVersion

catalog = load_catalog("default")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a section on top of create view to specify that in order to use the view endpoints from the catalog, the view configuration needs to have "view-endpoints-supported": "true"

from pyiceberg.catalog import load_catalog

catalog = load_catalog(
    "docs",
    **{
        "uri": "http://127.0.0.1:8181",
        "s3.endpoint": "http://127.0.0.1:9000",
        "py-io-impl": "pyiceberg.io.pyarrow.PyArrowFileIO",
        "s3.access-key-id": "admin",
        "s3.secret-access-key": "password",
        "view-endpoints-supported": "true",
    }
)

Comment thread mkdocs/docs/api.md
catalog.view_exists("default.bar")

identifier = "default.some_view"
schema = pa.schema([pa.field("some_col", pa.int32())])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for the example I believe would be best to show an Iceberg schema type instead of arrow but also note that create_view also accepts an arrow schema

Comment thread mkdocs/docs/api.md
catalog = load_catalog("default")
catalog.view_exists("default.bar")

identifier = "default.some_view"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would just put the string directly in the create_view call

Comment thread mkdocs/docs/api.md
version_id=1,
schema_id=1,
timestamp_ms=int(time.time() * 1000),
summary={},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
summary={},
summary={"spark-version": "4.1"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to show what the summary is usually used for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: Add documentation/examples of supported View operations

2 participants