Skip to content

Conversation

@nik9000
Copy link
Member

@nik9000 nik9000 commented Oct 12, 2022

This continues to populate the aggregations module with it's first
pipeline aggregation and it's first custom script context. It also moves
the script context that painless uses for it's execute API into the SPI
so we can attach the MovingFunctions to it so we don't break
backwards compatibility.

Relates to #90283

This continues to populate the `aggregations` module with it's first
pipeline aggregation and it's first custom script context.

Relates to elastic#90283
@nik9000 nik9000 requested review from jdconrad and martijnvg October 12, 2022 12:50
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Oct 12, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Copy link
Member Author

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I'm happy to break this into two changes if folks want. It really has two sets of reviewers. But I stuck it together to sort of explain the painless stuff.

I didn't move the MovingFunctions implementations. Those are still in core because the ml plugin relies on them. We can move them, but that requires a few more decisions I didn't want to make at this time.

public Set<ScriptContext<?>> getSupportedContexts() {
return Set.of(MovingFunctionScript.CONTEXT);
}
};
Copy link
Member Author

Choose a reason for hiding this comment

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

This is required because we MockScriptEngine can no longer provide a default implementation. So far as I can tell that implementation was only used for this test so I'm kind of happy to isolate it here anyway.

script: "MovingFunctions.min(values)"

---
"Bad window":
Copy link
Member Author

Choose a reason for hiding this comment

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

I combined the two test files we have for moving_fn

'painless/40_fields_api/filter script fields api',
'painless/40_fields_api/script score fields api'
'painless/40_fields_api/script score fields api',
'painless/70_mov_fn_agg/*' // Agg moved to a module.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is kind of a shame.

Copy link
Member

Choose a reason for hiding this comment

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

Right, because the integration test cluster started here doesn't have the analytics module and therefor the moving average pipeline aggregation isn't available when running these bwc yaml tests. We won't have this test coverage in the aggregations module, since the tests didn't exist in this module in earlier versions (in fact the entire module doesn't exist).

We can maybe think about adding the aggregations module to the painless test cluster? Then we don't lose test coverage?

request = new Request(new Script("MovingFunctions.max(new double[]{1, 3, 2})"), null, null);
response = innerShardOperation(request, scriptService, null);
assertEquals(3.0, Double.parseDouble((String) response.getResult()), .1);

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this to a yaml test in the aggregations module. It only works with that module enabled now.

@@ -1,47 +0,0 @@
# There are many more tests under modules/lang-painless/...moving_fn.yml so they can use painless
---
"Bad window":
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to the aggregations module

@nik9000 nik9000 requested a review from not-napoleon October 12, 2022 12:55
@nik9000
Copy link
Member Author

nik9000 commented Oct 12, 2022

This fails because we are pulling the aggregations module into the rest-api-spec. Mostly we're doing that because of BWC. We're also doing that because at some point we'll get to tests where we want to move one of the aggs and not yet others. I think we should bite the bullet and remove the dependency. In a follow up PR though.

@nik9000
Copy link
Member Author

nik9000 commented Oct 12, 2022

In a follow up PR though.

Well, in a pre-committed PR actually.

@nik9000
Copy link
Member Author

nik9000 commented Oct 12, 2022

#90851 would fix the error here I think.

Copy link
Contributor

@jdconrad jdconrad left a comment

Choose a reason for hiding this comment

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

From a purely scripting perspective this looks good to me! Thanks for updating this @nik9000.

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

LGTM, assuming that #90851 fixes the yaml test issues.

*/

package org.elasticsearch.search.aggregations.pipeline;
package org.elasticsearch.aggregations.pipeline;
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a package level java docs for pipeline package?

Copy link
Member

@not-napoleon not-napoleon left a comment

Choose a reason for hiding this comment

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

LGTM

@nik9000
Copy link
Member Author

nik9000 commented Oct 17, 2022

@elasticmachine, test this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Aggregations Aggregations >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants