[ES|QL] Implicit numeric casting for CASE/GREATEST/LEAST#122601
[ES|QL] Implicit numeric casting for CASE/GREATEST/LEAST#122601fang-xing-esql merged 4 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
|
Hi @fang-xing-esql, I've created a changelog YAML for you. |
costin
left a comment
There was a problem hiding this comment.
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,GREATESTandLEASTto 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.