-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Number-based alerts are broken #4279
Comments
I believe this is happens cause the threshold input field has been changed to accept texts (to accommodate text comparisons) so all new alerts yield a string from the threshold value. @rauchy @kravets-levko wdyt of handling this in the backend - casting both args to string for redash/redash/models/__init__.py Lines 826 to 847 in 5d58503
|
I think the solution could be something like: if alert's threshold value contains numeric string and query result's column type is number - cast both to number; otherwise cast both to string:
|
I think that if query result is a number, then we should try to cast both to number. In other cases: use a string. Because the operation options we show are based on the query result type, the threshold should adhere. We might want to enforce this in the UI. |
Not sure I understand why casting-by-value would be preferable to casting-by-operation. |
Because strings and numbers have different behavior, for example: In case of a number |
Aha. So I propose the following:
|
@susodapop reopening as the fix wasn't pushed to this repo yet. |
Issue Summary
It looks like the alert always sees a query result as a string and not a number. So an alert configured to trigger when
field = 0
never triggers because"0"
does not equal0
.The alerts seems to evaluate fine for targets that are obviously strings. If the alert should trigger if
field = boyhowdy
then the alert triggers whenfield
is "boyhowdy".Steps to Reproduce
SELECT 0 "value"
value = 0
The converse is also true, by the way.
value != 0
Technical details:
The text was updated successfully, but these errors were encountered: