-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Alerts aren't firing with error 'Alert query returned a non-number value.' when returning a date column #26298
Comments
@sadpandajoe @eschutho @betodealmeida @john-bodley Given that the threshold needs to be a double precision number, do the query always need to return a numeric value? If that's the case, are we missing a tooltip on the SQL input explaining this constraint? I'm assuming the execution log will contain the error when this constraint is not respected. |
This was working beforehand with a single digit so if we need double precision, it could potentially break for other people who don't currently have it. |
@sadpandajoe I believe the error is not related to the double precision but to the fact that the query is returning a non-numeric value. |
Per here it seems like SELECT year FROM main.wb_health_population LIMIT 1 be (assuming SQLite): SELECT CAST(strftime('%Y', year) AS INT) FROM main.wb_health_population LIMIT 1 |
@sadpandajoe found that this is a regression from #26187. We bumped Pyarrow from 12.x to 14.x and there was a breaking change that impacts the value of year from an int (or other numerical value) to a timestamp, thus breaking existing alerts if someone is (probably incorrectly) returning the year as an int. If we want to maintain our own backward compatibility, we could cast it back to an int somewhere in the codebase. I agree with @john-bodley that the alert query should probably have included an explicit casting of the value to an int instead of relying on Pyarrow for the conversion. I'm not sure all of the places where this change has impacted the codebase other than alerts, or if we want to consider this a bug fix rather than a breaking change. Thoughts? |
For context here's the line where @sadpandajoe's error was coming from. The Python >>> float('2023')
2023.0
>>> float('2023-12-01')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: '2023-12-01'
>>> |
@eschutho and @sadpandajoe are we sure this is a regression as I'm able to repro this using version Additionally, per #26298 (comment), it seems like the |
I've also been able to repro the behavior—which seems correct—on 3.0.2:
|
Reading the comments it seems this is not a bug but an expected error when the query returns something that is not numeric. It seems a follow up could be adding a tooltip to the SQL input to make this restriction more clear as I suggested here. |
@john-bodley yeah and if you do an alert based on that and in the successful logs you get |
@sadpandajoe I personally don't view this as a breaking change but more like a fix. Previously, if someone had a query that didn't return a numeric value, the application was wrongfully converting the return value and firing alerts under a incorrect condition evaluation. What the behavior should be is the current one, where errors are thrown when the condition cannot be evaluated. Right now, there are alerts that are being fired under false pretenses and they should stop working, or in other words, they should break. This change will give users the opportunity to fix misleading alerts that previously went unnoticed. |
A clear and concise description of what the bug is.
How to reproduce the bug
SELECT year FROM main.wb_health_population LIMIT 1
!=
0
Expected results
The alert is sent because the condition is met
Actual results
Send error with
Alert query returned a non-number value.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
(please complete the following information):
superset version
python --version
node -v
Checklist
Make sure to follow these steps before submitting your issue - thank you!
Additional context
Looks like the first failure was with this SHA
2ac28927a326fee6431b5e01f7930e650c636c17
The text was updated successfully, but these errors were encountered: