{"record":{"id":"777103a0a9319e28","repo":"getredash/redash","slug":"error-during-query-execution-reason-error","errorCode":null,"errorMessage":"Error during query execution. Reason: {error}","messagePattern":"Error during query execution\\. Reason: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"redash/query_runner/__init__.py","lineNumber":239,"sourceCode":"            column_name = col[0]\n            while column_name in column_names:\n                duplicates_counters[col[0]] += 1\n                column_name = \"{}{}\".format(col[0], duplicates_counters[col[0]])\n\n            column_names.add(column_name)\n            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","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/getredash/redash/blob/ca79fe988d81cdac9675b412f3dfcab107bc1fbc/redash/query_runner/__init__.py#L221-L257","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the embedded error text after 'Reason:' — it is the backend's message and points at the real cause","Grant the data source user SELECT on metadata catalogs (information_schema, SHOW TABLES equivalents) if permissions are the issue","Run the failing introspection SQL directly against the DB to reproduce","Update Redash if the runner's introspection SQL is incompatible with your DB version"],"exampleFix":"-- before: user lacks catalog access\nGRANT USAGE ON SCHEMA information_schema TO redash_ro;\n\n-- after\nGRANT USAGE ON SCHEMA information_schema TO redash_ro;\nGRANT SELECT ON ALL TABLES IN SCHEMA information_schema TO redash_ro;","handlingStrategy":"try-catch","validationCode":"# preflight: confirm the source can run queries at all\n_, err = ds.query_runner.run_query('SELECT 1', None)\nassert err is None, f'fix base connectivity first: {err}'","typeGuard":null,"tryCatchPattern":"try:\n    schema = ds.get_schema(get_stats=False)\nexcept Exception as e:\n    if 'Error during query execution' in str(e):\n        log(inner := str(e).split('Reason:', 1)[-1]); schema = []","preventionTips":["Use a DB user with metadata-catalog read privileges","Disable stats population on locked-down databases","Keep the runner version aligned with your DB engine version"],"tags":["redash","schema","database","introspection"],"backgroundTag":"schema-introspection-failed","analyzedSha":"ca79fe988d81cdac9675b412f3dfcab107bc1fbc","analyzedAt":"2026-08-28T18:32:34.637Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}