gabeiglio commented on code in PR #3414:
URL: https://github.com/apache/iceberg-python/pull/3414#discussion_r3302728293


##########
mkdocs/docs/api.md:
##########
@@ -1527,17 +1527,40 @@ def cleanup_old_snapshots(table_name: str, 
snapshot_ids: list[int]):
 cleanup_old_snapshots("analytics.user_events", [12345, 67890, 11111])
 ```
 
-## Views
+## Create a view
 
-PyIceberg supports view operations.
-
-### Check if a view exists
+To create a view from a catalog:
 
 ```python
+import time
+import pyarrow as pa
 from pyiceberg.catalog import load_catalog
+from pyiceberg.view import SQLViewRepresentation, ViewVersion
 
 catalog = load_catalog("default")

Review 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"`
   
   ```python
   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",
       }
   )
   ```



##########
mkdocs/docs/api.md:
##########
@@ -1527,17 +1527,40 @@ def cleanup_old_snapshots(table_name: str, 
snapshot_ids: list[int]):
 cleanup_old_snapshots("analytics.user_events", [12345, 67890, 11111])
 ```
 
-## Views
+## Create a view
 
-PyIceberg supports view operations.
-
-### Check if a view exists
+To create a view from a catalog:
 
 ```python
+import time
+import pyarrow as pa
 from pyiceberg.catalog import load_catalog
+from pyiceberg.view import SQLViewRepresentation, ViewVersion
 
 catalog = load_catalog("default")
-catalog.view_exists("default.bar")
+
+identifier = "default.some_view"

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



##########
mkdocs/docs/api.md:
##########
@@ -1527,17 +1527,40 @@ def cleanup_old_snapshots(table_name: str, 
snapshot_ids: list[int]):
 cleanup_old_snapshots("analytics.user_events", [12345, 67890, 11111])
 ```
 
-## Views
+## Create a view
 
-PyIceberg supports view operations.
-
-### Check if a view exists
+To create a view from a catalog:
 
 ```python
+import time
+import pyarrow as pa
 from pyiceberg.catalog import load_catalog
+from pyiceberg.view import SQLViewRepresentation, ViewVersion
 
 catalog = load_catalog("default")
-catalog.view_exists("default.bar")
+
+identifier = "default.some_view"
+schema = pa.schema([pa.field("some_col", pa.int32())])

Review 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



##########
mkdocs/docs/api.md:
##########
@@ -1527,17 +1527,40 @@ def cleanup_old_snapshots(table_name: str, 
snapshot_ids: list[int]):
 cleanup_old_snapshots("analytics.user_events", [12345, 67890, 11111])
 ```
 
-## Views
+## Create a view
 
-PyIceberg supports view operations.
-
-### Check if a view exists
+To create a view from a catalog:
 
 ```python
+import time
+import pyarrow as pa
 from pyiceberg.catalog import load_catalog
+from pyiceberg.view import SQLViewRepresentation, ViewVersion
 
 catalog = load_catalog("default")
-catalog.view_exists("default.bar")
+
+identifier = "default.some_view"
+schema = pa.schema([pa.field("some_col", pa.int32())])
+view_version = ViewVersion(
+    version_id=1,
+    schema_id=1,
+    timestamp_ms=int(time.time() * 1000),
+    summary={},

Review Comment:
   ```suggestion
       summary={"spark-version": "4.1"},
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to