-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Scripted metric aggs ignore script level params #28819
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
Comments
/cc @elastic/es-search-aggs |
@rjernst What should the behavior be if script params and aggregation params are provided with the same name? I'm inclined to think that should cause an error at I have a start to a PR on this. Pretty sure I have it working but it needs some trivial cleanup plus refinement for this conflict case. Input is appreciated if you'd welcome a PR. |
I think an error is the right thing. Right now, anything passed into params at the script level is ignored, so any errors that result of this change could only happen if a user is already either passing in params in both the script and one level up, or they are passing in Long term, I think |
Thanks, that makes sense. Agree that the aggregation status/results are really part of the context, not part of the parameters -- that does sound like a better design.
I will clean up my progress other than this new error case today and should be able to take care of the error case either this week or next weekend and submit the PR. |
(Another option is we could treat _agg/_aggs as a special case to disallow passing at the script level, but given your long term change suggestion that is not really moving in the right direction in general. Even passing non-"special" params in at both the aggregate and script level seems more like a confusing mistake than an important use case.) |
/cc @colings86 for your thoughts on the approach discussed here. |
Now params that are passed at the script level and at the aggregation level are merged and can both be used in the aggregation scripts. If there are any conflicts, aggregation level params will win. This may be followed by another change detecting that case and throwing an exception to disallow such conflicts.
…lastic#28819) If a scripted metric aggregation has aggregation params and script params which have the same name, throw an IllegalArgumentException when merging the parameter lists.
Agreed that an error would be the best approach for handling colliding keys in the params. I also agree that now we have script contexts it would be much better to expose the |
* Pass script level params into scripted metric aggs (#28819) Now params that are passed at the script level and at the aggregation level are merged and can both be used in the aggregation scripts. If there are any conflicts, aggregation level params will win. This may be followed by another change detecting that case and throwing an exception to disallow such conflicts. * Disallow duplicate parameter names between scripted agg and script (#28819) If a scripted metric aggregation has aggregation params and script params which have the same name, throw an IllegalArgumentException when merging the parameter lists.
* Pass script level params into scripted metric aggs (#28819) Now params that are passed at the script level and at the aggregation level are merged and can both be used in the aggregation scripts. If there are any conflicts, aggregation level params will win. This may be followed by another change detecting that case and throwing an exception to disallow such conflicts. * Disallow duplicate parameter names between scripted agg and script (#28819) If a scripted metric aggregation has aggregation params and script params which have the same name, throw an IllegalArgumentException when merging the parameter lists.
@rjernst can this be closed? |
Yes, closed by #29154. |
When scripts are specified, either in json or via
new Script()
, they take aparams
Map. Scripted metrics use multiple scripts, and take aparams
map at the outer level which applies to all of the 4 scripts of a scripted metric agg. However, the params passed directly to a script are lost.I traced this to a flaw in ScriptedMetricAggregationBuilder. The original Script object for each script, eg mapScript, needs to be passed through (or at least the params from it) to the ScriptedMetricAggregatorFactory, and then before running each script, the relevant per script params need to be merged in (by creating a new map and added the per script params).
The text was updated successfully, but these errors were encountered: