Skip to content

Read Unity Catalog tables

Use your Databricks CLI profile to read a table by its catalog name. DAR obtains temporary storage credentials through Unity Catalog, then reads the Delta data and runs SQL on your machine. You do not need a Databricks cluster or SQL warehouse.

The examples use Bash.

Before you start

  • Install DAR 0.8 or newer.
  • Install the Databricks CLI and have a working workspace profile. Its databricks executable must be on PATH in the same environment as DAR. DAR packages do not include it.
  • Choose a managed or external Delta table that permits direct reads. Your administrator must enable external data access and grant USE CATALOG, USE SCHEMA, SELECT, and EXTERNAL USE SCHEMA. Both the workspace and its storage must be reachable. See the access requirements if the table has policies or uses a special table type.

For a materialized view or streaming table, follow Read the latest published result below. A Delta table federated from Hive or AWS Glue uses the same commands, with external location access.

The Python and Rust APIs do not resolve uc:// names; this guide uses the CLI.

Set up or renew a user OAuth login

An existing working profile needs no new login. Otherwise, use your workspace URL and choose a profile name:

databricks auth login --host https://YOUR_WORKSPACE_HOST --profile work

Use the workspace URL, not the account console URL. Repeat this command if the login expires or is revoked. Login does not grant table permissions. For a service principal or PAT, follow Databricks CLI authentication.

Choose a snapshot

Replace the table name and profile below with yours. The name has three parts: uc://catalog.schema.table.

For a table stored in S3, also supply a region options file with --storage-options-file storage.json on each inspect, preview, scan, or query command.

table=uc://main.sales.orders
profile=work

Use your task's snapshot version. If none was supplied, discover one:

dar inspect "$table" --view summary --databricks-profile "$profile"

Inspection prints JSON containing table_version and read checks. It loads snapshot metadata; it does not prove that every data file is readable. If it includes time_travel: false, use the latest-only workflow instead of selecting a version. Otherwise, set version to the supplied version or returned table_version:

version=42

Replace 42 with your chosen version. If you do not know the needed column's exact name, search at that version with a likely prefix:

dar inspect "$table" --view summary --databricks-profile "$profile" \
  --table-version "$version" --column-prefix customer

Replace customer with a prefix relevant to your table. If too many names match, narrow the prefix. To inspect a column's type, replace --column-prefix customer with --column COLUMN_NAME, using a returned name.

Read a small sample

Choose a column relevant to your question, replacing customer_id below:

dar preview "$table" --databricks-profile "$profile" --table-version "$version" \
  --column customer_id --limit 3

This prints up to three rows as typed JSON in the terminal. Integer values are strings so large values remain exact. Row order is unspecified, and the result is marked sample. Preview defaults to an 8 KiB response budget and a 30-second deadline. Select only the columns and rows you need; see preview limits for overrides.

Save rows as Arrow

dar scan "$table" --databricks-profile "$profile" --table-version "$version" \
  --column customer_id --limit 10 --output orders.arrow

This saves at most ten values of the selected column as a binary Arrow IPC stream. Row order is unspecified. Choose an unused output name, then read the saved result with an Arrow IPC stream reader. A limited scan covers the requested prefix, not the whole table.

To select columns or filter rows, use the ordinary scan options and predicates with the same table, profile, and version.

Run SQL locally

A positional table is available to SQL as t. For example, count its rows:

cat > count.sql <<'SQL'
SELECT COUNT(*) AS row_count FROM t;
SQL
dar query "$table" --databricks-profile "$profile" --table-version "$version" \
  --sql-file count.sql --format json

The result prints as typed JSON, with completion: "complete". The query can read the whole snapshot even though it returns one row. SQL executes locally and uses the same authorization as a scan. See query limits for output and memory budgets, and the JSON reference for the response format.

Read the latest published result

Materialized views and streaming tables use the same uc:// name and Databricks profile. Their owner must first enable external metadata and refresh the object; see the requirements. DAR reads that published result locally. It does not refresh a view or start a streaming job.

For example, use a materialized view named main.sales.daily_orders:

dar inspect uc://main.sales.daily_orders --databricks-profile work --view summary
dar preview uc://main.sales.daily_orders --databricks-profile work --limit 3

For S3, add the region file to both commands. Use --column NAME when you know which column you need. A streaming table uses the same commands with its own name.

These objects support only the latest published snapshot. Inspection includes time_travel: false; result and plan bindings carry the same marker. The returned table_version records what was read, but cannot be selected in another command. Omit --table-version, including on retries. In a --tables-file entry, omit table_version for this object; other entries can still select versions.

You can run SQL with query, inspect a plan with explain, or save a result with scan --output or query --output. Each command resolves its own latest snapshot, so a refresh between commands can change the result. Save the output if you need to reuse those exact rows. The optional --manifest replay record is unavailable because it requires selectable historical snapshots.

Join with a local Delta table

Declare each table and its authorization in tables.json. Replace the UC name, profile, and both versions with your own. Inspect the local table only if its version was not supplied. Here, customers is a Delta directory beside the manifest:

For a materialized view or streaming table, omit that entry's table_version. The other table can still select a version.

{"format_version":1,"tables":[
  {"alias":"orders","location":"uc://main.sales.orders","table_version":"42",
   "authorization":{"source":"databricks","databricks_profile":"work"}},
  {"alias":"customers","location":"./customers","table_version":"0"}
]}

For tables with a customer_id column in common, save this as join.sql:

SELECT o.customer_id, COUNT(*) AS order_count
FROM orders o JOIN customers c ON o.customer_id = c.customer_id
GROUP BY o.customer_id
ORDER BY o.customer_id;
dar query --tables-file tables.json --sql-file join.sql --format json --output joined.json

Authorization now belongs to each manifest entry, so omit the command-line --databricks-profile. For S3-backed UC tables, add "storage_options_file":"./storage.json" inside that entry's authorization. Each table stays on its selected snapshot; the versions do not form a transaction across tables. Read the saved result after exit 0 and command completion. See the manifest reference for direct-storage tables, additional fields, and path rules.

If a command fails

Failure Next action
databricks_cli_missing Make databricks available on PATH in the environment running DAR, including inside a container.
databricks_cli_failed or databricks_cli_timeout Run the Databricks check below in the same environment. Check workspace connectivity and CLI compatibility.
uc_table_request_failed or uc_credential_request_failed Read the accompanying Databricks error. uc_authentication_failed means check the selected profile's login; uc_permission_denied means ask an administrator to check access and any named privilege. If the cause remains unclear, check Databricks directly.
uc_permission_denied naming EXTERNAL USE LOCATION Ask the owner of the named external location to grant that privilege, then retry the same command. This privilege belongs to the external location, not the table.
uc_s3_region_required Supply the S3 region file.
unsupported_uc_table Check the supported tables and credential forms.
unsupported_uc_catalog_protocol The workspace does not advertise Delta API 1.0 table reads. Additional grants do not add this protocol support.
uc_pipeline_external_access_unavailable Ask the owner to enable external metadata and refresh the materialized view or streaming table. Check the external access requirements.
uc_pipeline_time_travel_unsupported Omit --table-version or this object's table_version entry. Only the latest published snapshot is available.
uc_pipeline_replay_unsupported Keep --output and omit --manifest. Saved rows remain reusable; historical snapshot replay is unavailable.
uc_credentials_expired Check the system clock and renew user OAuth if needed, then retry.
Failure after output was written Discard failed stdout results. In file mode, preserve existing output and retry with an unused path if completion is uncertain. Keep the selected version where supported; latest-only objects can change between attempts. With --manifest, follow the manifest checks.

DAR renews storage credentials during a command. If renewal fails, the command fails; it never switches to another identity. See the Unity Catalog reference for credential forms, renewal rules, and tested compatibility, or CLI diagnostics for scripting and machine-readable errors.

Check Databricks directly

If DAR's filtered error does not explain the failure, run this read-only metadata request with the failing table and profile:

databricks tables get main.sales.orders --profile work \
  --include-manifest-capabilities --output json

Replace the table and profile with yours, without the uc:// prefix. This Databricks command does not use a cluster. Success confirms access to metadata; it does not prove that external storage credentials or data-file reads will succeed. An unknown flag means the CLI needs an update. For a timeout, check the workspace URL, network, and proxy settings; DAR gives each Databricks request 30 seconds.