{"record":{"id":"388913092c0bc6d9","repo":"getredash/redash","slug":"failed-running-query-s","errorCode":null,"errorMessage":"Failed running query [%s].","messagePattern":"Failed running query \\[(.+?)\\]\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"redash/query_runner/__init__.py","lineNumber":245,"sourceCode":"            new_columns.append({\"name\": column_name, \"friendly_name\": column_name, \"type\": col[1]})\n\n        return new_columns\n\n    def get_schema(self, get_stats=False):\n        raise NotSupported()\n\n    def _handle_run_query_error(self, error):\n        if error is None:\n            return\n\n        logger.error(error)\n        raise Exception(f\"Error during query execution. Reason: {error}\")\n\n    def _run_query_internal(self, query):\n        results, error = self.run_query(query, None)\n\n        if error is not None:\n            raise Exception(\"Failed running query [%s].\" % query)\n        return results[\"rows\"]\n\n    @classmethod\n    def to_dict(cls):\n        return {\n            \"name\": cls.name(),\n            \"type\": cls.type(),\n            \"configuration_schema\": cls.configuration_schema(),\n            **({\"deprecated\": True} if cls.deprecated else {}),\n        }\n\n    @property\n    def supports_auto_limit(self):\n        return False\n\n    def apply_auto_limit(self, query_text, should_apply_auto_limit):\n        return query_text\n","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/query_runner/__init__.py#L227-L263","documentation":"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.","triggerScenarios":"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.","commonSituations":"Stats gathering (get_stats=True) hitting tables the connection user cannot select, hyphenated/reserved identifiers needing quoting, or heavy stats queries timing out.","solutions":["Disable 'populate schema with stats' on the data source if stats queries fail","Grant SELECT on the table named in the embedded query","Quote problematic identifiers or update to a runner version that does","Check Redash logs for the underlying backend error preceding this exception"],"exampleFix":"# before: data source settings\n{\"get_stats\": true}\n\n# after\n{\"get_stats\": false}","handlingStrategy":"try-catch","validationCode":"# preflight the stats query on a representative table\nSELECT 1 FROM <table> LIMIT 1;","typeGuard":null,"tryCatchPattern":"try:\n    tables = runner.get_schema(get_stats=True)\nexcept Exception as e:\n    if str(e).startswith('Failed running query'):\n        tables = runner.get_schema(get_stats=False)  # fallback without stats","preventionTips":["Leave get_stats off by default; enable only where permissions allow","Grant SELECT on queried tables to the reporting user","Alert on schema-refresh failures to catch permission drift"],"tags":["redash","database","query-stats"],"backgroundTag":"sql-execution-failed","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}