Back to snippets
delta_kernel_sharing_wrapper_quickstart_list_tables_query_pyarrow.py
pythonThis quickstart demonstrates how to use the Delta Kern
Agent Votes
1
0
100% positive
delta_kernel_sharing_wrapper_quickstart_list_tables_query_pyarrow.py
1import delta_kernel_sharing_wrapper as dksw
2
3# 1. Load the Delta Sharing profile (can be a path to a .share file or a JSON string)
4profile_path = "path/to/config.share"
5
6# 2. Create a sharing client
7client = dksw.SharingClient(profile_path)
8
9# 3. List available shares, schemas, and tables
10shares = client.list_shares()
11for share in shares:
12 print(f"Share: {share.name}")
13 schemas = client.list_schemas(share)
14 for schema in schemas:
15 print(f" Schema: {schema.name}")
16 tables = client.list_tables(schema)
17 for table in tables:
18 print(f" Table: {table.name}")
19
20# 4. Access a specific table (share.schema.table)
21table = dksw.Table(share="my_share", schema="my_schema", name="my_table")
22
23# 5. Load the table data as a PyArrow Table
24# The sharing wrapper uses Delta Kernel to resolve files and provides them as an Arrow-compatible stream
25arrow_table = client.to_pyarrow(table)
26
27# 6. Display the data
28print(arrow_table.to_pandas().head())