-
Notifications
You must be signed in to change notification settings - Fork 1.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
Evaluates COALESCE arguments past first non-NULL value #8910
Comments
This might share the root cause with #8909. |
This may be fixed by #8928 |
This issue is related with #8928 but is different with it. Let me have explain this problem: It's cause by When we try to #8928 avoid how do you think about it? @alamb @liukun4515 BTW, Are @haohuaijin interested in this? If yes, when you meet some problem or need review, please feel free to @me. |
Thank you @jackwener. I am interested in it. I have two solutions. FirstWe can first fold the expression whenever, and if we encounter an error, return the origin expression in the below code, and the error will occur in runtime if it is a real error(not the short-circuit problem). Seconddon't simplify short-circuit expressions' all sub-expressions. I think this issue is also related to #8927, because the scalar function first evaluates all args and then execution the actual function, so even though we don't fold the expression, the query in this issue will also throw error.
|
This makes sense to me @haohuaijin and @jackwener - I also played around with posgres and this seems consistent with what it does. |
Describe the bug
Datafusion evaluates
COALESCE(a, b, c)
expressions even past the first non-NULL value, and bubbles up runtime errors from them.This is wrong because the COALESCE could be explicitly protecting against e.g. the divide-by-zero case, and differs from other sql engines.
To Reproduce
Expected behavior
COALESCE
to return the first non-NULL value, not bubble up errors from the rest.Compare to SQLite:
Compare to Postgres:
Additional context
No response
The text was updated successfully, but these errors were encountered: