pola-rs/polars · error · ValueError
cannot {operation}: no data_source_format found
Error message
cannot {operation}: no data_source_format found What it means
Companion to the missing-location error: `_extract_location_and_data_format` (client.py:746) requires both `storage_location` and `data_source_format` on the Unity Catalog TableInfo. Polars dispatches on the format (DELTA/DELTASHARING get Delta-specific reads/writes, PARQUET/CSV/etc. get plain cloud reads), so a null `data_source_format` raises ValueError 'cannot scan table: no data_source_format found'. It means the catalog returned table metadata that does not declare what physical format the files are in.
Source
Thrown at py-polars/src/polars/catalog/unity/client.py:755
msg = (
"did not receive credentials from temporary credentials API for "
f"{table_id = }"
)
raise Exception(msg) # noqa: TRY002
yield creds, expiry
def _extract_location_and_data_format(
table_info: TableInfo, operation: str
) -> tuple[str, DataSourceFormat]:
if table_info.storage_location is None:
msg = f"cannot {operation}: no storage_location found"
raise ValueError(msg)
if table_info.data_source_format is None:
msg = f"cannot {operation}: no data_source_format found"
raise ValueError(msg)
return table_info.storage_location, table_info.data_source_format
View on GitHub (pinned to df599052da)
Solutions
- Inspect `client.get_table_info(...).data_source_format` first and fail with a clear message if None
- Recreate/repair the table registration so it declares a format (e.g. CREATE EXTERNAL TABLE ... STORED AS PARQUET LOCATION ..., or resync via UC)
- If the underlying files are Parquet/Delta and you know the path, read them directly: `pl.scan_delta(location)` or `pl.scan_parquet(location)` with the storage_location and credentials you already have
- Upgrade the polars-cloud/unity SDK client if a stale API version is dropping the field
Example fix
# before
lf = catalog.scan_table("main", "sales", "legacy_synced_tbl") # data_source_format is None
# after
info = catalog.get_table_info("main", "sales", "legacy_synced_tbl")
if info.data_source_format is None:
# bypass catalog dispatch, read the files directly
lf = pl.scan_parquet(info.storage_location, storage_options=...) # requires location
else:
lf = catalog.scan_table("main", "sales", "legacy_synced_tbl") Defensive patterns
Strategy: validation
Validate before calling
info = catalog.get_table_info(catalog_name, namespace, table_name)
if info.data_source_format is None:
raise ValueError(f"table {tbl} declares no data_source_format; cannot dispatch reader") Type guard
from polars.catalog.unity.models import TableInfo
def has_known_format(info: TableInfo) -> bool:
return info.data_source_format is not None Try / catch
try:
lf = catalog.scan_table(cat, ns, tbl)
except ValueError as e:
if "no data_source_format found" in str(e):
# fallback: read the raw files if location exists
info = catalog.get_table_info(cat, ns, tbl)
if info.storage_location and info.storage_location.endswith(('.parquet', '/')):
return pl.scan_parquet(info.storage_location, storage_options=storage_options)
raise Prevention
- Validate both storage_location and data_source_format in one preflight check
- Keep format metadata correct at table-creation time (STORED AS / USING clauses)
- When bypassing the catalog, pin the reader to the format you verified on disk
When it happens
Trigger: `catalog.scan_table(...)` or `catalog.write_table(...)` on a table whose UC metadata has data_source_format = null: typically non-Delta external tables registered without a format, foreign tables, objects created by third-party metastore sync tools, or an older UC workspace/API version that does not populate the field for the object type being read.
Common situations: Hive metastore-to-UC migrations that leave format null on synced tables; tables created via direct REST 'createTable' calls that skipped data_source_format; reading views or system objects never intended to be scanned; SDK version older than the workspace API returning sparse metadata.
Related errors
- cannot {operation}: no storage_location found
- a non-HTTPS workspace_url was given ({workspace_url}). To al
- cannot apply delta_table_version for table of type {data_sou
- cannot apply delta_table_options for table of type {data_sou
- write_table: table format of {catalog_name}.{namespace}.{tab
AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16).
Data as JSON: /api/errors/d9d70e3501806c23.
Report an issue: GitHub.