Add more examples for pyiceberg view#3414
Conversation
gabeiglio
left a comment
There was a problem hiding this comment.
Thanks for the PR! left some small comments but overall looks good
| from pyiceberg.catalog import load_catalog | ||
| from pyiceberg.view import SQLViewRepresentation, ViewVersion | ||
|
|
||
| catalog = load_catalog("default") |
There was a problem hiding this comment.
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",
}
)| catalog.view_exists("default.bar") | ||
|
|
||
| identifier = "default.some_view" | ||
| schema = pa.schema([pa.field("some_col", pa.int32())]) |
There was a problem hiding this comment.
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
| catalog = load_catalog("default") | ||
| catalog.view_exists("default.bar") | ||
|
|
||
| identifier = "default.some_view" |
There was a problem hiding this comment.
Nit: I would just put the string directly in the create_view call
| version_id=1, | ||
| schema_id=1, | ||
| timestamp_ms=int(time.time() * 1000), | ||
| summary={}, |
There was a problem hiding this comment.
| summary={}, | |
| summary={"spark-version": "4.1"}, |
There was a problem hiding this comment.
Just to show what the summary is usually used for
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.