{"record":{"id":"a4fef18259b88c1e","repo":"getredash/redash","slug":"failed-to-get-tables-error","errorCode":null,"errorMessage":"Failed to get tables: {error}","messagePattern":"Failed to get tables: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"redash/query_runner/duckdb.py","lineNumber":123,"sourceCode":"                [(d[0], TYPES_MAP.get(d[1].upper(), TYPE_STRING)) for d in cursor.description]\n            )\n            rows = [dict(zip((col[\"name\"] for col in columns), row)) for row in cursor.fetchall()]\n            data = {\"columns\": columns, \"rows\": rows}\n            return data, None\n        except duckdb.InterruptException:\n            raise InterruptException(\"Query cancelled by user.\")\n        except Exception as e:\n            logger.exception(\"Error running query: %s\", e)\n            return None, str(e)\n\n    def get_schema(self, get_stats=False) -> list:\n        tables_query = \"\"\"\n            SELECT table_catalog, table_schema, table_name FROM information_schema.tables\n            WHERE table_schema NOT IN ('information_schema', 'pg_catalog');\n        \"\"\"\n        tables_results, error = self.run_query(tables_query, None)\n        if error:\n            raise Exception(f\"Failed to get tables: {error}\")\n\n        schema = {}\n        for table_row in tables_results[\"rows\"]:\n            # Include catalog (database) in the full table name for MotherDuck support\n            catalog = table_row[\"table_catalog\"]\n            schema_name = table_row[\"table_schema\"]\n            table_name = table_row[\"table_name\"]\n\n            # Skip catalog prefix for default local databases (memory, temp)\n            # but include it for MotherDuck and attached databases\n            if catalog.lower() in (\"memory\", \"temp\", \"system\"):\n                full_table_name = f\"{schema_name}.{table_name}\"\n                describe_query = f'DESCRIBE \"{schema_name}\".\"{table_name}\";'\n            else:\n                full_table_name = f\"{catalog}.{schema_name}.{table_name}\"\n                describe_query = f'DESCRIBE \"{catalog}\".\"{schema_name}\".\"{table_name}\";'\n\n            schema[full_table_name] = {\"name\": full_table_name, \"columns\": []}","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/query_runner/duckdb.py#L105-L141","documentation":"DuckDB runner's get_schema runs an information_schema.tables query through run_query; if that helper returns an error it raises 'Failed to get tables: <error>' with DuckDB's own failure message embedded.","triggerScenarios":"Refreshing the schema when the SELECT against information_schema.tables fails — e.g. an attached MotherDuck database unreachable, corrupted catalog, or metadata visibility issues.","commonSituations":"MotherDuck token expired or remote database offline, a damaged .duckdb file, or DuckDB version incompatibilities with information_schema.","solutions":["Check the inner error string — it is DuckDB's own failure reason","If using MotherDuck: verify the token and that the remote database is reachable","Run the same information_schema query in the DuckDB CLI to reproduce","Re-create or re-attach the data source if the file or catalog is corrupted"],"exampleFix":"# before: attached remote db unreachable\nSELECT table_catalog, table_schema, table_name FROM information_schema.tables;\n\n# after: verify attachment first\nATTACH 'md:mydb' AS md (TOKEN '<valid-token>');\nSELECT * FROM md.information_schema.tables;","handlingStrategy":"try-catch","validationCode":"q = \"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','pg_catalog')\"\n_, err = runner.run_query(q, None)\nassert err is None, f'schema listing will fail: {err}'","typeGuard":null,"tryCatchPattern":"try:\n    schema = runner.get_schema()\nexcept Exception as e:\n    if str(e).startswith('Failed to get tables:'):\n        log(e); schema = {}  # continue without the schema panel","preventionTips":["Validate MotherDuck tokens and remote attachments before refresh","Keep DuckDB files on storage visible to all workers","Pin a DuckDB version compatible with your runner version"],"tags":["redash","duckdb","schema","information-schema"],"backgroundTag":"schema-introspection-failed","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}