{"record":{"id":"302d155a65548a03","repo":"pola-rs/polars","slug":"could-not-get-databricks-token-databricks-sdk-is","errorCode":null,"errorMessage":"could not get Databricks token: databricks-sdk is not installed","messagePattern":"could not get Databricks token: databricks-sdk is not installed","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/catalog/unity/client.py","lineNumber":704,"sourceCode":"            ), storage_options\n\n        # This should generally not happen, but if using the temporary\n        # credentials API fails for whatever reason, we fallback to our built-in\n        # credential provider resolution.\n\n        from polars.io.cloud.credential_provider._builder import (\n            _init_credential_provider_builder,\n        )\n\n        return _init_credential_provider_builder(\n            \"auto\", table_info.storage_location, storage_options, caller_name\n        ), storage_options\n\n    @classmethod\n    def _get_databricks_token(cls) -> str:\n        if importlib.util.find_spec(\"databricks.sdk\") is None:\n            msg = \"could not get Databricks token: databricks-sdk is not installed\"\n            raise ImportError(msg)\n\n        # We code like this to bypass linting\n        m = importlib.import_module(\"databricks.sdk.core\").__dict__\n\n        return m[\"DefaultCredentials\"]()(m[\"Config\"]())()[\"Authorization\"][7:]\n\n\nclass CatalogCredentialProvider:\n    \"\"\"Retrieves credentials from the Unity catalog temporary credentials API.\"\"\"\n\n    catalog: Catalog\n    table_id: str\n    write: bool\n\n    def __init__(self, catalog: Catalog, table_id: str, *, write: bool) -> None:\n        self.catalog = catalog\n        self.table_id = table_id\n        self.write = write","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/catalog/unity/client.py#L686-L722","documentation":"ImportError from Catalog._get_databricks_token (py-polars/src/polars/catalog/unity/client.py:699-709). When bearer_token='databricks-sdk' (or the 'auto' path resolves to SDK-based auth inside a Databricks runtime), polars must read the workspace credentials via the databricks-sdk package; importlib.util.find_spec('databricks.sdk') returning None means the SDK is not installed in the environment, and the token cannot be retrieved. polars does not depend on databricks-sdk, so it must be installed separately.","triggerScenarios":"Catalog(workspace_url=..., bearer_token='databricks-sdk') without `pip install databricks-sdk`; CI images missing the optional dependency; 'auto' mode inside DATABRICKS_RUNTIME_VERSION environments that lack the SDK.","commonSituations":"New deployment environments where only polars was installed; slim Docker images; local dev mimicking Databricks auth without the SDK installed.","solutions":["pip install databricks-sdk (add to requirements/devcontainer)","Alternatively pass an explicit bearer_token string so no SDK lookup is needed","Verify visibility before the call: importlib.util.find_spec('databricks.sdk') is not None"],"exampleFix":"# before\nCatalog(workspace_url=url, bearer_token='databricks-sdk')  # ImportError\n\n# after\n# shell: pip install databricks-sdk\nCatalog(workspace_url=url, bearer_token='databricks-sdk')","handlingStrategy":"validation","validationCode":"import importlib.util\n\ndef databricks_sdk_available() -> bool:\n    return importlib.util.find_spec('databricks.sdk') is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add databricks-sdk to the environment/requirements when using bearer_token='databricks-sdk'","Check find_spec('databricks.sdk') at startup of catalog-based pipelines","Alternatively provision a static bearer_token to avoid the SDK dependency"],"tags":["polars","unity-catalog","databricks-sdk","optional-dependency","importerror"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}