roryqi commented on code in PR #10778:
URL: https://github.com/apache/gravitino/pull/10778#discussion_r3084371716


##########
docs/iceberg-rest-engine/pyiceberg.md:
##########
@@ -0,0 +1,112 @@
+---
+title: Connect PyIceberg via Iceberg REST
+sidebar_label: PyIceberg
+---
+
+# Connecting PyIceberg via Iceberg REST
+
+Apache Gravitino exposes an [Iceberg REST catalog](../iceberg-rest-service.md) 
endpoint that any
+Iceberg-compatible client can connect to directly. This page describes how to 
use PyIceberg with
+Gravitino's Iceberg REST (IRC) endpoint.
+
+## Prerequisites
+
+- Apache Gravitino running with the Iceberg REST service enabled. See
+  [Iceberg REST catalog service](../iceberg-rest-service.md) for setup 
instructions.
+- The Gravitino IRC endpoint is accessible from your Python environment. The 
default port is `9001`.
+- PyIceberg installed: `pip install pyiceberg`
+
+## Configuration
+
+```python
+from pyiceberg.catalog import load_catalog
+
+catalog = load_catalog(
+    "gravitino_irc",
+    **{
+        "type": "rest",
+        "uri":  "http://<gravitino-host>:9001/iceberg",
+    }
+)
+```
+
+### With credential vending
+
+```python
+catalog = load_catalog(
+    "gravitino_irc",
+    **{
+        "type":                            "rest",
+        "uri":                             
"http://<gravitino-host>:9001/iceberg",
+        "header.X-Iceberg-Access-Delegation": "vended-credentials",
+    }
+)
+```
+
+### With OAuth2 authentication
+
+```python
+catalog = load_catalog(
+    "gravitino_irc",
+    **{
+        "type":  "rest",
+        "uri":   "http://<gravitino-host>:9001/iceberg",
+        "token": "<your-token>",
+    }
+)
+```
+
+See [How to authenticate](../security/how-to-authenticate.md) for Gravitino 
authentication
+configuration options.
+
+## Usage examples
+
+### List namespaces
+
+```python
+catalog.list_namespaces()
+```
+
+### Load a table
+
+```python
+table = catalog.load_table("db.table")
+print(table.schema())
+```
+
+### Scan a table
+
+```python
+df = table.scan().to_arrow()
+print(df)
+```
+
+### Create a namespace and table
+
+```python
+catalog.create_namespace("db")
+
+from pyiceberg.schema import Schema
+from pyiceberg.types import NestedField, LongType, StringType
+
+schema = Schema(
+    NestedField(1, "id",   LongType(),   required=True),
+    NestedField(2, "name", StringType(), required=False),
+)
+catalog.create_table("db.new_table", schema=schema)
+```
+
+## Gravitino connector vs Iceberg REST
+
+| Feature | Gravitino Engine Connector | Iceberg REST |

Review Comment:
   Could u align the table columns?



-- 
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]

Reply via email to