-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
[Scripting] BWC Incompatible Change for Bucket Aggregation Context #35351
Comments
Pinging @elastic/es-core-infra |
Here is a reproduction case:
All is good... now introduce a
Re-run the search and
|
Briefly talked to @rjernst about this. I'm thinking over the behavior of return values in Painless. It's possible it makes more sense to make a change to casting model in the singular case because it will be better for the user. |
I'd be in favour of this as a short-term fix. We did exactly this elsewhere too when trying to make the new contexts return a specific type and running into trouble. |
Fixed by #35653 |
…lastic#35653) This change fixes elastic#35351. Users were no longer able to return types of numbers other than doubles for bucket aggregation scripts. This change reverts to the previous behavior of being able to return any type of number and having it converted to a double outside of the script.
Recent changes to the bucket aggregation context are backwards incompatible for specific return cases in Painless (#32068). The expected return within this context changed from
def (Object)
toDouble
. This causes an issue with casting as it is illegal to cast from one boxed type to another. This means that scripts previously were allowed to do the following wherevalue
is adef
representingdouble
:value > 0 ? value : 0
This previous script allowed the auto-return mechanism to cast
0
toInteger
and return that sincedef
was the expected return type. Now this will cause a ClassCastException because casting fromInteger
toDouble
is not allowed in Painless or Java (included as we follow a casting model very similar to Java's).My recommended fix is to have this context return
Object
for now until we can come up with a better solution for deprecation. Note that if this context didn't requirenull
, it would be okay to usedouble
since it's legal to cast fromint
todouble
as unboxed types.This started in version 6.5 and was caught by a Kibana script using a similar example to the one given.
ping @original-brownbear @rjernst
The text was updated successfully, but these errors were encountered: