unity catalog

GuideConnect engines and clients

Query Unity Catalog tables from Python DataFrame libraries

Find, read, and append to external Delta tables in Unity Catalog from Polars, Daft, and pandas, with storage credentials vended by the server.

Polars, Daft, and pandas can find Unity Catalog tables by name and read and append to them. Each library looks up the table, asks the server for temporary storage credentials, and then reads or writes the Delta files directly in storage.

All three work with external Delta tables, through delta-rs. For catalog-managed tables, use Spark or DuckDB, which commit through the server.

The Polars and pandas examples use a table on S3, and the Daft examples a table on local storage, which is what each library is tested with here. The local environment above simulates S3. On real AWS, leave its AWS_ENDPOINT_URL and AWS_ALLOW_HTTP variables unset.

Connect to the server

Open a Python session with Polars:

uv run --with polars==1.44.2 --with deltalake==1.6.6 python
polars_tables.pyFull script
import polars as pl

catalog = pl.Catalog("http://localhost:8080", require_https=False)

pl.Catalog takes the server's base URL, without /api/2.1/unity-catalog. require_https=False allows the local http:// address. On a secured server, pass a Unity Catalog access token as bearer_token. Polars marks pl.Catalog as unstable, so its API may change in any release.

List tables

polars_tables.pyFull script
for table in catalog.list_tables("retail", "sales"):
    print(table.name, table.table_type, table.storage_location)
orders EXTERNAL s3://uc-docs/retail/orders

list_catalogs() and list_namespaces(catalog) list the levels above.

deltalake can't list tables. With pandas, use the Python client to find them.

Read a table

polars_tables.pyFull script
orders = catalog.scan_table("retail", "sales", "orders")
print(orders.filter(pl.col("amount") > 5).collect())

scan_table returns a LazyFrame, so filters run as Polars reads the files.

Each library requests read credentials for the table's location from the server, and then reads the Delta files with them. For how vending works, see Credential vending.

Append rows

polars_tables.pyFull script
new_orders = pl.DataFrame(
    {"order_id": [4], "customer": ["margaret"], "amount": [12.0]}
)
catalog.write_table(new_orders, "retail", "sales", "orders", delta_mode="append")

The library requests read-write credentials, writes new Parquet files, and commits a new version to the table's Delta log. The server isn't involved in the commit, so it doesn't coordinate writers on an external table.

Other table operations

Create and drop tables with the Python client or Spark.

Required privileges

With authorization enabled, reading needs USE CATALOG on the catalog, USE SCHEMA on the schema, and SELECT on the table. Appending also needs MODIFY on the table. Owners have all of these. See Core concepts.

Next steps