def _validate_operator(self, rows: np.recarray) -> None: # check if query return more then one row if len(rows) > 1: raise AlertQueryMultipleRowsError( message=_( "Alert query returned more then one row. %s rows returned" % len(rows), ) ) # check if query returned more then one column if len(rows[0]) > 2: raise AlertQueryMultipleColumnsError( _( "Alert query returned more then one column. %s columns returned" % len(rows[0]) ) ) if rows[0][1] is None: return try: # Check if it's float or if we can convert it self._result = float(rows[0][1]) return except (AssertionError, TypeError, ValueError): raise AlertQueryInvalidTypeError()
def _validate_result(rows: np.recarray) -> None: # check if query return more then one row if len(rows) > 1: raise AlertQueryMultipleRowsError(message=_( "Alert query returned more then one row. %s rows returned" % len(rows), )) # check if query returned more then one column if len(rows[0]) > 2: raise AlertQueryMultipleColumnsError( # len is subtracted by 1 to discard pandas index column _("Alert query returned more then one column. %s columns returned" % (len(rows[0]) - 1)))