getredash/redash · error · Exception

Failed to get tables: {error}

Error message

Failed to get tables: {error}

What it means

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.

Source

Thrown at redash/query_runner/duckdb.py:123

                [(d[0], TYPES_MAP.get(d[1].upper(), TYPE_STRING)) for d in cursor.description]
            )
            rows = [dict(zip((col["name"] for col in columns), row)) for row in cursor.fetchall()]
            data = {"columns": columns, "rows": rows}
            return data, None
        except duckdb.InterruptException:
            raise InterruptException("Query cancelled by user.")
        except Exception as e:
            logger.exception("Error running query: %s", e)
            return None, str(e)

    def get_schema(self, get_stats=False) -> list:
        tables_query = """
            SELECT table_catalog, table_schema, table_name FROM information_schema.tables
            WHERE table_schema NOT IN ('information_schema', 'pg_catalog');
        """
        tables_results, error = self.run_query(tables_query, None)
        if error:
            raise Exception(f"Failed to get tables: {error}")

        schema = {}
        for table_row in tables_results["rows"]:
            # Include catalog (database) in the full table name for MotherDuck support
            catalog = table_row["table_catalog"]
            schema_name = table_row["table_schema"]
            table_name = table_row["table_name"]

            # Skip catalog prefix for default local databases (memory, temp)
            # but include it for MotherDuck and attached databases
            if catalog.lower() in ("memory", "temp", "system"):
                full_table_name = f"{schema_name}.{table_name}"
                describe_query = f'DESCRIBE "{schema_name}"."{table_name}";'
            else:
                full_table_name = f"{catalog}.{schema_name}.{table_name}"
                describe_query = f'DESCRIBE "{catalog}"."{schema_name}"."{table_name}";'

            schema[full_table_name] = {"name": full_table_name, "columns": []}

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Check the inner error string — it is DuckDB's own failure reason
  2. If using MotherDuck: verify the token and that the remote database is reachable
  3. Run the same information_schema query in the DuckDB CLI to reproduce
  4. Re-create or re-attach the data source if the file or catalog is corrupted

Example fix

# before: attached remote db unreachable
SELECT table_catalog, table_schema, table_name FROM information_schema.tables;

# after: verify attachment first
ATTACH 'md:mydb' AS md (TOKEN '<valid-token>');
SELECT * FROM md.information_schema.tables;
Defensive patterns

Strategy: try-catch

Validate before calling

q = "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','pg_catalog')"
_, err = runner.run_query(q, None)
assert err is None, f'schema listing will fail: {err}'

Try / catch

try:
    schema = runner.get_schema()
except Exception as e:
    if str(e).startswith('Failed to get tables:'):
        log(e); schema = {}  # continue without the schema panel

Prevention

When it happens

Trigger: Refreshing the schema when the SELECT against information_schema.tables fails — e.g. an attached MotherDuck database unreachable, corrupted catalog, or metadata visibility issues.

Common situations: MotherDuck token expired or remote database offline, a damaged .duckdb file, or DuckDB version incompatibilities with information_schema.

Related errors


AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28). Data as JSON: /api/errors/a4fef18259b88c1e. Report an issue: GitHub.