{"record":{"id":"d9d70e3501806c23","repo":"pola-rs/polars","slug":"cannot-operation-no-data-source-format-found","errorCode":null,"errorMessage":"cannot {operation}: no data_source_format found","messagePattern":"cannot (.+?): no data_source_format found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/catalog/unity/client.py","lineNumber":755,"sourceCode":"            msg = (\n                \"did not receive credentials from temporary credentials API for \"\n                f\"{table_id = }\"\n            )\n            raise Exception(msg)  # noqa: TRY002\n\n        yield creds, expiry\n\n\ndef _extract_location_and_data_format(\n    table_info: TableInfo, operation: str\n) -> tuple[str, DataSourceFormat]:\n    if table_info.storage_location is None:\n        msg = f\"cannot {operation}: no storage_location found\"\n        raise ValueError(msg)\n\n    if table_info.data_source_format is None:\n        msg = f\"cannot {operation}: no data_source_format found\"\n        raise ValueError(msg)\n\n    return table_info.storage_location, table_info.data_source_format\n","sourceCodeStart":737,"sourceCodeEnd":758,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/catalog/unity/client.py#L737-L758","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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"],"exampleFix":"# before\nlf = catalog.scan_table(\"main\", \"sales\", \"legacy_synced_tbl\")  # data_source_format is None\n\n# after\ninfo = catalog.get_table_info(\"main\", \"sales\", \"legacy_synced_tbl\")\nif info.data_source_format is None:\n    # bypass catalog dispatch, read the files directly\n    lf = pl.scan_parquet(info.storage_location, storage_options=...)  # requires location\nelse:\n    lf = catalog.scan_table(\"main\", \"sales\", \"legacy_synced_tbl\")","handlingStrategy":"validation","validationCode":"info = catalog.get_table_info(catalog_name, namespace, table_name)\nif info.data_source_format is None:\n    raise ValueError(f\"table {tbl} declares no data_source_format; cannot dispatch reader\")","typeGuard":"from polars.catalog.unity.models import TableInfo\n\ndef has_known_format(info: TableInfo) -> bool:\n    return info.data_source_format is not None","tryCatchPattern":"try:\n    lf = catalog.scan_table(cat, ns, tbl)\nexcept ValueError as e:\n    if \"no data_source_format found\" in str(e):\n        # fallback: read the raw files if location exists\n        info = catalog.get_table_info(cat, ns, tbl)\n        if info.storage_location and info.storage_location.endswith(('.parquet', '/')):\n            return pl.scan_parquet(info.storage_location, storage_options=storage_options)\n    raise","preventionTips":["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"],"tags":["unity-catalog","delta-lake","metadata","polars"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}