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

Require combine and reduce scripts in scripted metrics aggregation #33452

Merged
merged 19 commits into from
Oct 3, 2018

Conversation

albendz
Copy link
Contributor

@albendz albendz commented Sep 6, 2018

Fixes #32804

Implementation notes:

  • Integration and unit tests updated
  • Throws IllegalArgumentException when combine or reduce is not provided
  • only unit tests test for exceptions, integration only tests positive cases
  • Behavior:
    no combine, no reduce -> exception
    combine, no reduce -> exception
    no combine, reduce -> exception
    combine, reduce -> success

@tlrx tlrx added the :Analytics/Aggregations Aggregations label Sep 6, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@albendz
Copy link
Contributor Author

albendz commented Sep 10, 2018

Since first creating this there is now a conflict. Do I need to resolve the conflicts before anyone takes a look?

Copy link
Contributor

@colings86 colings86 left a comment

Choose a reason for hiding this comment

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

@albendz I left a small comment but I think this looks pretty good. If you could address that and update the branch with the latest master I'll kick of a CI build

throw new IllegalArgumentException("[combineScript] must not be null: [" + name + "]");
}

if(reduceScript == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we do these null checks at the start of the method before we compile any scripts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

@albendz
Copy link
Contributor Author

albendz commented Sep 12, 2018

@colings86 I tried moving the null checks but it changed the test behavior. The init scripts might be setting those values so the order might need to stay afterwards. It takes some time to rerun the tests so I'll keep trying to figure this out but it will take a while.

compiledCombineScript = queryShardContext.getScriptService().compile(combineScript,
ScriptedMetricAggContexts.CombineScript.CONTEXT);
combineScriptParams = combineScript.getParams();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should leave lines 204-206 here where they were below but just have the null check here so here its just:

if (combineScript == null) {
    throw new IllegalArgumentException("[combineScript] must not be null: [" + name + "]");
}

And then below after the map script parts we have:

ScriptedMetricAggContexts.CombineScript.Factory compiledCombineScript = queryShardContext.getScriptService().compile(combineScript, ScriptedMetricAggContexts.CombineScript.CONTEXT);
Map<String, Object> combineScriptParams = combineScript.getParams();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making this change causes all the integ tests to fail and I haven't been able to debug why yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all = all the scripted metric IT integ tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I said, this combination fails the integration tests and I'm not sure why. It seems the return values of the test scripts are returning different values if done this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I'm currently debugging issues with the dummy scripts interfering with return values. It takes a while since they are integ tests. Just letting you know I'm still working on this.

@albendz
Copy link
Contributor Author

albendz commented Sep 16, 2018

Fixed - integ tests should have failed for my initial script but for whatever reason they did not (possibly because of a failed clean task).

@colings86
Copy link
Contributor

@elasticmachine test this please

@colings86
Copy link
Contributor

@albendz it looks like the build for an unrelated reason. Would you mind updating the branch with the latest master and I'll set the tests off again?

@albendz
Copy link
Contributor Author

albendz commented Sep 27, 2018

I've updated the branch. Some unrelated tests failed but that might be slowness from my machine.

@colings86
Copy link
Contributor

@elasticmachine test this please

@colings86
Copy link
Contributor

@albendz I think this change looks good now. However I have forgotten about two things that will need to be done before this can be merged:

  1. We should add a note in the breaking changes documentation so users upgrading to 7.0.0 can see that this behaviour has changed
  2. Although this breaking change will happen in 7.0.0 we should prepare a PR for the 6.x branch which instead of throwing an exception logs a warning with the deprecation logger so if users on later 6.x release do not specify a combine or reduce script when using the scripted_metric aggregation they will be notified that their scripted metric aggregation will not work

Are you happy to make these changes? Sorry for not raising this to you before, doing this two things had slipped my mind.

@albendz
Copy link
Contributor Author

albendz commented Oct 1, 2018

I will try to get started on these changes but I will be unavailable for 3 weeks starting Oct 4. I'll see how far I get!

@albendz
Copy link
Contributor Author

albendz commented Oct 2, 2018

Can you give me an example of what using the deprecation logger looks like?

@albendz
Copy link
Contributor Author

albendz commented Oct 3, 2018

Created 6.x PR: #34254

Copy link
Contributor

@colings86 colings86 left a comment

Choose a reason for hiding this comment

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

Thanks for the work and for creating the 6.x version of this change. providing the current test runs succeed I'll go ahead an merge these changes

@colings86
Copy link
Contributor

@elasticmachine test this please

@colings86
Copy link
Contributor

@albendz thanks for working on this, I've merged this change into master and 6.x

gwbrown added a commit that referenced this pull request Oct 29, 2018
When combine_script and reduce_script were made into required
parameters for Scripted Metric aggregations in #33452, the docs were
not updated to reflect that. This marks those parameters as required
in the documentation.
kcm pushed a commit that referenced this pull request Oct 30, 2018
…33452)

* Make text message not required in constructor for slack

* Remove unnecessary comments in test file

* Throw exception when reduce or combine is not provided; update tests

* Update integration tests for scripted metrics to always include reduce and combine

* Remove some old changes from previous branches

* Rearrange script presence checks to be earlier in build

* Change null check order in script builder for aggregated metrics; correct test scripts in IT

* Add breaking change details to PR
kcm pushed a commit that referenced this pull request Oct 30, 2018
When combine_script and reduce_script were made into required
parameters for Scripted Metric aggregations in #33452, the docs were
not updated to reflect that. This marks those parameters as required
in the documentation.
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants