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

Update Painless Fields API design to use mapped types #78950

Merged
merged 9 commits into from
Oct 13, 2021

Conversation

jdconrad
Copy link
Contributor

This change updates the Painless fields API to use mapped types instead of Java types. For this initial release we only support unsigned long field.

As we now intend to do conversions solely on the field classes themselves, converters and field values have been removed. Instead of using field values potentially as source fallback we will now rely on whatever class is passed into the script to support the field method. In the future, this method will need to check if a field exists on doc and if not, then do source fallback itself once that feature is supported.

The path to retrieve a field is also different. Instead of using script doc values we now have our own way to retrieve the fields with a getScriptField method added to LeafDocLookup. This allows us less restrictive design space to generate the field type based the type in the leaf doc lookup; however, this will still require additional information that we need to plumb through for certain field types. Once we support all the field types this makes it easier to deprecate and remove script doc values.

@jdconrad jdconrad added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring v8.0.0 v7.16.0 labels Oct 11, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Oct 11, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@jdconrad jdconrad added the auto-backport Automatically create backport pull requests when merged label Oct 11, 2021
@jdconrad
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/part-2

Copy link
Contributor

@stu-elastic stu-elastic left a comment

Choose a reason for hiding this comment

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

We can reuse a lot of the removed tests when we implement basic types in the new design, so let's save those (as requested above).

Copy link
Contributor

@stu-elastic stu-elastic left a comment

Choose a reason for hiding this comment

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

Can you find a way to share the same doc values across ScriptDocValues and and DocValuesField? Having a penalty for using the fields API and doc in the same script is pretty rough for adoption and is surprising behavior.

Copy link
Contributor

@stu-elastic stu-elastic 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

@stu-elastic @rjernst Thanks for the in depth reviews! I'm still working toward addressing all the feedback, and will commit once that's done.

@jdconrad jdconrad merged commit ce614ce into elastic:master Oct 13, 2021
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
7.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 78950

@jdconrad jdconrad added backport pending and removed auto-backport Automatically create backport pull requests when merged labels Oct 13, 2021
jdconrad added a commit to jdconrad/elasticsearch that referenced this pull request Oct 14, 2021
This change updates the Painless fields API to use mapped types instead of Java types. For this initial
release we only support unsigned long field.

As we now intend to do conversions solely on the field classes themselves, converters and field values
have been removed. Instead of using field values potentially as source fallback we will now rely on
whatever class is passed into the script to support the field method. In the future, this method will
need to check if a field exists on doc and if not, then do source fallback itself once that feature is
supported.

The path to retrieve a field is also different. Instead of using script doc values we now have our own
way to retrieve the fields with a getScriptField method added to LeafDocLookup. This allows us less
restrictive design space to generate the field type based the type in the leaf doc lookup; however, this
will still require additional information that we need to plumb through for certain field types. Once we
support all the field types this makes it easier to deprecate and remove script doc values.
jdconrad added a commit that referenced this pull request Oct 18, 2021
…79201)

This change updates the Painless fields API to use mapped types instead of Java types. For this initial 
release we only support unsigned long field.

As we now intend to do conversions solely on the field classes themselves, converters and field values 
have been removed. Instead of using field values potentially as source fallback we will now rely on 
whatever class is passed into the script to support the field method. In the future, this method will 
need to check if a field exists on doc and if not, then do source fallback itself once that feature is 
supported.

The path to retrieve a field is also different. Instead of using script doc values we now have our own 
way to retrieve the fields with a getScriptField method added to LeafDocLookup. This allows us less 
restrictive design space to generate the field type based the type in the leaf doc lookup; however, this 
will still require additional information that we need to plumb through for certain field types. Once we 
support all the field types this makes it easier to deprecate and remove script doc values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport pending :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring Team:Core/Infra Meta label for core/infra team v7.16.0 v8.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants