Ingest Unity Catalog metadata and Delta Lake tables from Databricks into Semantica’s KG pipeline.
Extract Delta Lake tables and Unity Catalog metadata (schemas, lineage) from Databricks into Semantica with personal access token or OAuth M2M authentication.
# Install with Databricks supportpip install "semantica[db-databricks]"# Or install the connectors separatelypip install databricks-sdk databricks-sql-connector
from semantica.ingest import DatabricksIngestorimport osingestor = DatabricksIngestor( host=os.getenv("DATABRICKS_HOST"), # e.g. https://adb-xxx.azuredatabricks.net token=os.getenv("DATABRICKS_TOKEN"), http_path=os.getenv("DATABRICKS_HTTP_PATH"), # SQL warehouse or cluster HTTP path catalog=os.getenv("DATABRICKS_CATALOG", "main"), schema=os.getenv("DATABRICKS_SCHEMA", "default"),)data = ingestor.ingest_table("customers")print(f"Retrieved {data.row_count} rows: columns: {data.columns}")
Use environment variables (or a .env file with python-dotenv) to keep credentials out of source code. DatabricksIngestor() with no arguments reads from DATABRICKS_* environment variables automatically.
Preferred for production: no long-lived personal token stored in config.
http_path identifies the SQL warehouse or all-purpose cluster used for query execution. Find it in the Databricks UI under SQL Warehouses → Connection details. Unity Catalog metadata calls (list_catalogs, get_table_schema, get_table_lineage, …) only need host and credentials — http_path is not required for those.
data = ingestor.ingest_query(""" SELECT customer_id, SUM(amount) AS total_amount FROM main.default.sales WHERE date >= '2024-01-01' GROUP BY customer_id""")
lineage = ingestor.get_table_lineage("customers", catalog="main", schema="default")print(lineage["upstream"]) # tables that feed into `customers`print(lineage["downstream"]) # tables derived from `customers`
Use get_table_lineage to build Table --DEPENDS_ON--> Table edges in the knowledge graph directly from Unity Catalog’s lineage tracking, without re-deriving lineage from query logs.
Pass include_column_lineage=True to also resolve per-column upstream/downstream references (one extra Unity Catalog request per column, so it’s opt-in):