{"record":{"id":"7cdd3407f0d6fe6d","repo":"getredash/redash","slug":"resource-only-available-for-the-databricks-query-r","errorCode":null,"errorMessage":"Resource only available for the Databricks query runner.","messagePattern":"Resource only available for the Databricks query runner\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"redash/handlers/databricks.py","lineNumber":22,"sourceCode":"from redash import models, redis_connection\nfrom redash.handlers.base import BaseResource, get_object_or_404\nfrom redash.permissions import require_access, view_only\nfrom redash.serializers import serialize_job\nfrom redash.tasks.databricks import (\n    get_database_tables_with_columns,\n    get_databricks_databases,\n    get_databricks_table_columns,\n    get_databricks_tables,\n)\nfrom redash.utils import json_loads\n\n\ndef _get_databricks_data_source(data_source_id, user, org):\n    data_source = get_object_or_404(models.DataSource.get_by_id_and_org, data_source_id, org)\n    require_access(data_source, user, view_only)\n\n    if not data_source.type == \"databricks\":\n        abort(400, message=\"Resource only available for the Databricks query runner.\")\n\n    return data_source\n\n\ndef _databases_key(data_source_id):\n    return \"databricks:databases:{}\".format(data_source_id)\n\n\ndef _tables_key(data_source_id, database_name):\n    return \"databricks:database_tables:{}:{}\".format(data_source_id, database_name)\n\n\ndef _get_databases_from_cache(data_source_id):\n    cache = redis_connection.get(_databases_key(data_source_id))\n    return json_loads(cache) if cache else None\n\n\ndef _get_tables_from_cache(data_source_id, database_name):","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/handlers/databricks.py#L4-L40","documentation":"Raised by _get_databricks_data_source in redash/handlers/databricks.py when the requested data source exists and is accessible but its type is not 'databricks'. The Databricks-specific endpoints (listing databases/tables/schemas) only work against Databricks query runners.","triggerScenarios":"Calling /api/data_sources/<id>/databricks/databases (or the tables endpoint) with the id of a PostgreSQL, Athena, or any non-Databricks data source.","commonSituations":"Copying an integration example but pointing at the wrong data source id; migrating a data source from another runner to Databricks and hitting the old id before re-creating it; UI scripts enumerating all data sources and calling Databricks endpoints on each.","solutions":["Use the data source id whose type is 'databricks' (verify via GET /api/data_sources).","If you need databases/tables for other runner types, use their own schema endpoints (e.g. /api/data_sources/<id>/schema).","Re-create or reconfigure the data source as a Databricks type if that was intended."],"exampleFix":"# before\nresp = client.get(f'/api/data_sources/{pg_ds_id}/databricks/databases')\n\n# after\nresp = client.get(f'/api/data_sources/{databricks_ds_id}/databricks/databases')","handlingStrategy":"type-guard","validationCode":"ds = client.get(f'/api/data_sources/{ds_id}')\nassert ds['type'] == 'databricks', f\"expected databricks, got {ds['type']}\"","typeGuard":"def is_databricks(ds: dict) -> bool:\n    return ds.get('type') == 'databricks'","tryCatchPattern":null,"preventionTips":["Store the Databricks data source id in a named config key, not a bare integer.","Never run Databricks-only endpoints in a loop over all data sources without a type filter."],"tags":["redash","databricks","data-source","bad-request"],"backgroundTag":"wrong-resource-type","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}