Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2025 02:40 PM
Hey @tonykun_sg ,
I share with you a complete example of delta sharing 🙂
import delta_sharing
import json
# Point to the profile file. It can be a file on the local file system or a file on a remote storage.
profile_file = "config.share"
# Create a SharingClient.
client = delta_sharing.SharingClient(profile_file)
# Show tables
tables = client.list_all_tables()
for t in tables:
print(t)
# Read table
table_url = profile_file + "#<share-name>.<schema-name>.<table-name>"
df_table = delta_sharing.load_as_pandas(table_url)
print(df_table.head())
# Read using table predicates example
predicate_hints = {
"op": "and",
"children": [
{
"op": "equal",
"children": [
{"op": "column", "name": "is_outlet", "valueType": "int"},
{"op": "literal", "value": 0, "valueType": "int"}
]
},
{
"op": "equal",
"children": [
{"op": "column", "name": "iso_country", "valueType": "string"},
{"op": "literal", "value": "AD", "valueType": "string"}
]
}
]
}
predicate_hints_json = json.dumps(predicate_hints)
df_table_2 = delta_sharing.load_as_pandas(
table_url,
jsonPredicateHints=predicate_hints_json
)
print(df_table_2.head())In my example my config.share is in the same path, locally. Maybe you could save in Azure Key Vault retrieve the value and save in temporary file to avoid this problem.
Hope this helps 🙂