getredash/redash · error · Exception

Failed running query [%s].

Error message

Failed running query [%s].

What it means

Thrown by BaseQueryRunner._run_query_internal when run_query returns a non-None error while executing helper SQL used for table stats or schema listing. Unlike error [1] it embeds the raw query in the message; on success it returns the result rows.

Source

Thrown at redash/query_runner/__init__.py:245

            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
    def supports_auto_limit(self):
        return False

    def apply_auto_limit(self, query_text, should_apply_auto_limit):
        return query_text

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Disable 'populate schema with stats' on the data source if stats queries fail
  2. Grant SELECT on the table named in the embedded query
  3. Quote problematic identifiers or update to a runner version that does
  4. Check Redash logs for the underlying backend error preceding this exception

Example fix

# before: data source settings
{"get_stats": true}

# after
{"get_stats": false}
Defensive patterns

Strategy: try-catch

Validate before calling

# preflight the stats query on a representative table
SELECT 1 FROM <table> LIMIT 1;

Try / catch

try:
    tables = runner.get_schema(get_stats=True)
except Exception as e:
    if str(e).startswith('Failed running query'):
        tables = runner.get_schema(get_stats=False)  # fallback without stats

Prevention

When it happens

Trigger: Any internal helper call — _get_tables or _get_tables_stats — whose run_query errors, e.g. the SELECT ... LIMIT 100 stats query failing due to missing SELECT permission or an unquoted reserved table name.

Common situations: Stats gathering (get_stats=True) hitting tables the connection user cannot select, hyphenated/reserved identifiers needing quoting, or heavy stats queries timing out.

Related errors


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