getredash/redash · error · Exception

Error during query execution. Reason: {error}

Error message

Error during query execution. Reason: {error}

What it means

A generic wrapper thrown by BaseQueryRunner._handle_run_query_error after a schema-introspection helper (get_schema, _get_tables, get_databases, etc.) receives a non-None error from the underlying run_query. It surfaces the backend's own error text to the caller so schema-discovery failures aren't swallowed.

Source

Thrown at redash/query_runner/__init__.py:239

            column_name = col[0]
            while column_name in column_names:
                duplicates_counters[col[0]] += 1
                column_name = "{}{}".format(col[0], duplicates_counters[col[0]])

            column_names.add(column_name)
            new_columns.append({"name": column_name, "friendly_name": column_name, "type": col[1]})

        return new_columns

    def get_schema(self, get_stats=False):
        raise NotSupported()

    def _handle_run_query_error(self, error):
        if error is None:
            return

        logger.error(error)
        raise Exception(f"Error during query execution. Reason: {error}")

    def _run_query_internal(self, query):
        results, error = self.run_query(query, None)

        if error is not None:
            raise Exception("Failed running query [%s]." % query)
        return results["rows"]

    @classmethod
    def to_dict(cls):
        return {
            "name": cls.name(),
            "type": cls.type(),
            "configuration_schema": cls.configuration_schema(),
            **({"deprecated": True} if cls.deprecated else {}),
        }

    @property

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Read the embedded error text after 'Reason:' — it is the backend's message and points at the real cause
  2. Grant the data source user SELECT on metadata catalogs (information_schema, SHOW TABLES equivalents) if permissions are the issue
  3. Run the failing introspection SQL directly against the DB to reproduce
  4. Update Redash if the runner's introspection SQL is incompatible with your DB version

Example fix

-- before: user lacks catalog access
GRANT USAGE ON SCHEMA information_schema TO redash_ro;

-- after
GRANT USAGE ON SCHEMA information_schema TO redash_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA information_schema TO redash_ro;
Defensive patterns

Strategy: try-catch

Validate before calling

# preflight: confirm the source can run queries at all
_, err = ds.query_runner.run_query('SELECT 1', None)
assert err is None, f'fix base connectivity first: {err}'

Try / catch

try:
    schema = ds.get_schema(get_stats=False)
except Exception as e:
    if 'Error during query execution' in str(e):
        log(inner := str(e).split('Reason:', 1)[-1]); schema = []

Prevention

When it happens

Trigger: Opening the schema sidebar or calling GET /api/data_sources/<id>/schema when the introspection SQL the runner executes fails on the data source, e.g. permission denied on information_schema or unsupported syntax in the runner's catalog query.

Common situations: Read-only DB credentials lacking system-catalog access, an older runner emitting SQL unsupported by a newer DB engine, or network drops between Redash and the database during schema refresh.

Related errors


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