Skip to content

Side Effects in Painless During Scripted Metric Aggregation #53679

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

Closed
jdconrad opened this issue Mar 17, 2020 · 4 comments
Closed

Side Effects in Painless During Scripted Metric Aggregation #53679

jdconrad opened this issue Mar 17, 2020 · 4 comments
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache Team:Core/Infra Meta label for core/infra team

Comments

@jdconrad
Copy link
Contributor

jdconrad commented Mar 17, 2020

I want to discuss the behavior described here by @hendrikmuhs :

I have a design question: Painless lets me get the source via e.g. 
params['_source']. In the context of scripted metric you get a nasty side-
effect passing a value created from params['_source'] from one phase to the 
next. Because it works by reference, the content of a painless variable 
changes and you get wrong results. In order to work correctly you must 
create a copy by e.g. using new HashMap(params['_source']).

I wonder whether this is a bug. Full example: https://discuss.elastic.co/t/latest-full-document-in-transform/221435/4

Questions:

  1. Is this a bug?
  2. What behavior do we expect here?
@jdconrad jdconrad added >bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache labels Mar 17, 2020
@elasticmachine
Copy link
Collaborator

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

@stu-elastic
Copy link
Contributor

Related: #52103

@rjernst rjernst added the Team:Core/Infra Meta label for core/infra team label May 4, 2020
@rjernst rjernst added the needs:triage Requires assignment of a team area label label Dec 3, 2020
@stu-elastic stu-elastic removed the needs:triage Requires assignment of a team area label label Dec 9, 2020
@stu-elastic
Copy link
Contributor

We should parse params and emit read only maps and lists.

@rjernst
Copy link
Member

rjernst commented Apr 3, 2025

Source fields should be accessed through the fields API now.

@rjernst rjernst closed this as completed Apr 3, 2025
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 Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

No branches or pull requests

4 participants