apache/superset · error · AlertQueryError

Alert query must be a single statement

Error message

Alert query must be a single statement

What it means

Error "Alert query must be a single statement" thrown in apache/superset.

Source

Thrown at superset/commands/report/alert.py:194

        return (
            self._report_schedule.validator_type == ReportScheduleValidatorType.OPERATOR
        )

    def _get_alert_metadata_from_object(self) -> dict[str, Any]:
        return {
            "report_schedule_id": self._report_schedule.id,
            "execution_id": self._execution_id,
        }

    def _validate_rendered_sql(self, rendered_sql: str) -> None:
        """
        Enforce SQL-level constraints on the rendered alert query: a single
        statement, and no mutations unless the database allows DML.
        """
        database = self._report_schedule.database
        script = SQLScript(rendered_sql, engine=database.backend)
        if len(script.statements) != 1:
            raise AlertQueryError(message=_("Alert query must be a single statement"))
        if script.has_mutation() and not database.allow_dml:
            raise AlertQueryError(message=_("Alert query must be read-only"))

    @logs_context(context_func=_get_alert_metadata_from_object)
    def _execute_query(self) -> pd.DataFrame:
        """
        Executes the actual alert SQL query template

        :return: A pandas dataframe
        :raises AlertQueryError: SQL query is not valid
        :raises AlertQueryTimeout: The SQL query received a celery soft timeout
        """
        sql_template = jinja_context.get_template_processor(
            database=self._report_schedule.database
        )

        try:
            rendered_sql = sql_template.process_template(self._report_schedule.sql)

View on GitHub (pinned to f4587218dd)

Solutions

  1. Remove extra statements; the alert query must be a single SELECT statement.

When it happens

Trigger: The alert SQL contains multiple statements.

Common situations: Configuring an alert whose SQL contains multiple statements separated by semicolons.


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/0b2dcf314190cf5e. Report an issue: GitHub.