{"record":{"id":"0b2dcf314190cf5e","repo":"apache/superset","slug":"alert-query-must-be-a-single-statement","errorCode":null,"errorMessage":"Alert query must be a single statement","messagePattern":"Alert query must be a single statement","errorType":"exception","errorClass":"AlertQueryError","httpStatus":400,"severity":"error","filePath":"superset/commands/report/alert.py","lineNumber":194,"sourceCode":"        return (\n            self._report_schedule.validator_type == ReportScheduleValidatorType.OPERATOR\n        )\n\n    def _get_alert_metadata_from_object(self) -> dict[str, Any]:\n        return {\n            \"report_schedule_id\": self._report_schedule.id,\n            \"execution_id\": self._execution_id,\n        }\n\n    def _validate_rendered_sql(self, rendered_sql: str) -> None:\n        \"\"\"\n        Enforce SQL-level constraints on the rendered alert query: a single\n        statement, and no mutations unless the database allows DML.\n        \"\"\"\n        database = self._report_schedule.database\n        script = SQLScript(rendered_sql, engine=database.backend)\n        if len(script.statements) != 1:\n            raise AlertQueryError(message=_(\"Alert query must be a single statement\"))\n        if script.has_mutation() and not database.allow_dml:\n            raise AlertQueryError(message=_(\"Alert query must be read-only\"))\n\n    @logs_context(context_func=_get_alert_metadata_from_object)\n    def _execute_query(self) -> pd.DataFrame:\n        \"\"\"\n        Executes the actual alert SQL query template\n\n        :return: A pandas dataframe\n        :raises AlertQueryError: SQL query is not valid\n        :raises AlertQueryTimeout: The SQL query received a celery soft timeout\n        \"\"\"\n        sql_template = jinja_context.get_template_processor(\n            database=self._report_schedule.database\n        )\n\n        try:\n            rendered_sql = sql_template.process_template(self._report_schedule.sql)","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/report/alert.py#L176-L212","documentation":"Error \"Alert query must be a single statement\" thrown in apache/superset.","triggerScenarios":"The alert SQL contains multiple statements.","commonSituations":"Configuring an alert whose SQL contains multiple statements separated by semicolons.","solutions":["Remove extra statements; the alert query must be a single SELECT statement."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}