Skip to content
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

[Painless] Partially fixes def boxed types casting #35563

Closed
wants to merge 4 commits into from

Conversation

jdconrad
Copy link
Contributor

An issue related to implicitly casting to appropriate return types was revealed (#35351). According to the Painless spec (https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-casting.html), def values are allowed to implicitly cast from one boxed type to another boxed type such as Integer to Double. Currently, this not working according to spec. This partially fixes the issue by inserting appropriate methods at compile-time to execute the casts at run-time. The other part of the issue will be a different PR as it needs to fix an issue related to boxing for method parameters at run-time which is trickier due to run-time code path.

@jdconrad jdconrad added >bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v7.0.0 v6.6.0 v6.5.1 labels Nov 14, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, just one question.

public static Byte defToByteExplicit(final Object value) {
if (value == null) {
return null;
} else if (value instanceof Character) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought byte -> char and char -> byte had to be explicit (in java). Does painless differ here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, you are correct. This is a bug that I'll fix now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this is the explicit version, though. I corrected the implicit versions.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdconrad
Copy link
Contributor Author

@rjernst Thanks for the review! Will commit as soon as CI passes.

@jdconrad
Copy link
Contributor Author

I'm closing this in favor of the quick/easier fix for now (#35653). The casting model in Painless needs to be revisited in a separate follow up as some of the specced out casts do not work as expected, but the fixes need to be given more thought so more problems are not created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v6.6.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants