apache/superset · error · AlertQueryError

Alert query must be read-only

Error message

Alert query must be read-only

What it means

Error "Alert query must be read-only" thrown in apache/superset.

Source

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

        )

    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)
            self._validate_rendered_sql(rendered_sql)
            limited_rendered_sql = self._report_schedule.database.apply_limit_to_sql(

View on GitHub (pinned to f4587218dd)

Solutions

  1. Remove INSERT/UPDATE/DELETE and other mutating statements; use a read-only SELECT.

When it happens

Trigger: The alert query attempts to mutate data, which alerts forbid.

Common situations: Configuring an alert with INSERT/UPDATE/DELETE or other mutating SQL; alerts must be read-only SELECT queries.


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