{"record":{"id":"95ae856a78fe944f","repo":"apache/superset","slug":"alert-query-returned-more-than-one-row-num-rows","errorCode":null,"errorMessage":"Alert query returned more than one row. %(num_rows)s rows returned","messagePattern":"Alert query returned more than one row\\. (.+?) rows returned","errorType":"exception","errorClass":"AlertQueryMultipleRowsError","httpStatus":422,"severity":"error","filePath":"superset/commands/report/alert.py","lineNumber":134,"sourceCode":"            return (triggered, None)\n        except (KeyError, json.JSONDecodeError) as ex:\n            raise AlertValidatorConfigError() from ex\n\n    def _validate_not_null(self, rows: np.recarray[Any, Any]) -> None:\n        self._validate_result(rows)\n        value = rows[0][1]\n        # Normalize NULL/NaN to None for consistency with _validate_operator\n        if value is None or pd.isna(value):\n            self._result = None\n            self._info_message = \"Query returned NULL value\"\n            return\n        self._result = value\n\n    @staticmethod\n    def _validate_result(rows: np.recarray[Any, Any]) -> None:\n        # check if query return more than one row\n        if len(rows) > 1:\n            raise AlertQueryMultipleRowsError(\n                message=_(\n                    \"Alert query returned more than one row. %(num_rows)s rows returned\",  # noqa: E501\n                    num_rows=len(rows),\n                )\n            )\n        # check if query returned more than one column\n        if len(rows[0]) > 2:\n            raise AlertQueryMultipleColumnsError(\n                # len is subtracted by 1 to discard pandas index column\n                _(\n                    \"Alert query returned more than one column. \"\n                    \"%(num_cols)s columns returned\",\n                    num_cols=(len(rows[0]) - 1),\n                )\n            )\n\n    def _validate_operator(self, rows: np.recarray[Any, Any]) -> None:\n        self._validate_result(rows)","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/report/alert.py#L116-L152","documentation":"Error \"Alert query returned more than one row. %(num_rows)s rows returned\" thrown in apache/superset.","triggerScenarios":"The alert query returns more than one row; alerts require a single scalar result.","commonSituations":"Executing an alert whose SQL query returns multiple rows; alert validators require a single-row result.","solutions":["Rewrite the alert SQL so it returns exactly one row (e.g., add aggregation or LIMIT 1)."],"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-15T22:17:37.221Z"}