-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
[ES|QL] Implicit numeric casting for CASE/GREATEST/LEAST #122601
[ES|QL] Implicit numeric casting for CASE/GREATEST/LEAST #122601
Conversation
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Hi @fang-xing-esql, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM however we should look into generalizing this by looking at the param declaration instead of specific functions.
💔 Backport failed
You can use sqren/backport to manually backport by running |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
) * implicit numeric casting for conditional functions (cherry picked from commit 412e6c2) # Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
@fang-xing-esql just to double check, since we're backporting this to 9.0, did we intend to also backport this to 8.18 (which is kinda-sorta in sync with 9.0)? Not that this is a technical requirement, just something that stood out to me. |
Good point! I'll back port this to 8.18 as well. |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
Resolves #121890
#111917 supports implicit casting for numeric values and fields in
COALEASE
, the subsequent numeric arguments are casted to the first not null numeric type argument. This PR follow the same path to supportCASE
,GREATEST
andLEAST
to have the same behavior asCOALESCE
.For example,
GREATEST(Long, Int) returns a Long
LEAST(null, Long, Int) returns a Long
CASE(condition1, Double, condition2, Long, Int) returns a Double
GREATEST(Int, Long) returns
VerificationException
, because Long cannot be casted to Int.Technically, we can make the implicit casting independent of the sequence how the numeric values and fields are coded in the query, so that the query #4 above can run to completion, if this is the desired behavior.