Skip to content

Conversation

@tandonks
Copy link
Contributor

@tandonks tandonks commented Jun 1, 2025

Description

We had introduced the support for searching rollup and raw indices together in this opensearch-project/index-management#1268 but there was a bug in this due to class cast exception error when trying to reduce InternalValueCount and InternalAggregation as both used InternalScriptedMetric in their aggregation builder here. So this PR fixes this issue by introducing support for InternalScriptedMetric when trying to reduce these aggregations. Also included tests to cover these changes

Related PR: #18288

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@tandonks tandonks changed the title Tandonks test 2 Making changes in InternalValueCount and InternalAvg to support Scripted metric in reducing aggregation Jun 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2025

❌ Gradle check result for 1397185: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Member

@sandeshkr419 sandeshkr419 left a comment

Choose a reason for hiding this comment

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

I saw the comment on https://github.com/opensearch-project/index-management/blame/main/src/main/kotlin/org/opensearch/indexmanagement/rollup/util/RollupUtils.kt#L263

How early was it tested that the value count aggregation does not fulfil what you need?
I see some comments on type conversions, which I guess should be doable for value counts given that value counts will be a whole number for sure (I guess).


Now I don't fully understand your use-case in IM, but is it feasible to sum & value-count from core as it is and then calculate sum/value-count in IM plugin? Also, please check my comment in InternalAvg.java as well.

@tandonks tandonks requested a review from peternied as a code owner August 5, 2025 07:12
@tandonks tandonks force-pushed the tandonks-test-2 branch 2 times, most recently from 001f7e8 to e3811a7 Compare August 5, 2025 07:32
…ted metric in reducing agggregation

Signed-off-by: Kshitij Tandon <[email protected]>
…e and value count aggregations

Signed-off-by: Kshitij Tandon <[email protected]>
Signed-off-by: Kshitij Tandon <[email protected]>
Signed-off-by: Kshitij Tandon <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

❌ Gradle check result for 41bd4e5: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Kshitij Tandon <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

❌ Gradle check result for 9eaeccb: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Kshitij Tandon <[email protected]>
Signed-off-by: Kshitij Tandon <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

❌ Gradle check result for c1b4da4: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2025

✅ Gradle check result for 594c2c3: SUCCESS

@codecov
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 73.52941% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.92%. Comparing base (cc20ac7) to head (221f56b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...earch/search/aggregations/metrics/ScriptedAvg.java 46.15% 7 Missing ⚠️
...earch/search/aggregations/metrics/InternalAvg.java 91.66% 0 Missing and 1 partial ⚠️
...earch/aggregations/metrics/InternalValueCount.java 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #18411      +/-   ##
============================================
+ Coverage     72.87%   72.92%   +0.05%     
- Complexity    69326    69362      +36     
============================================
  Files          5641     5642       +1     
  Lines        318474   318504      +30     
  Branches      46062    46068       +6     
============================================
+ Hits         232076   232276     +200     
+ Misses        67581    67438     -143     
+ Partials      18817    18790      -27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

✅ Gradle check result for 221f56b: SUCCESS

@bharath-techie bharath-techie merged commit 2fedeb5 into opensearch-project:main Aug 6, 2025
31 checks passed
Copy link
Member

@sandeshkr419 sandeshkr419 left a comment

Choose a reason for hiding this comment

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

@tandonks Since the changes have already been merged, can you please fix the license header in a new PR?

Thanks!

Comment on lines +9 to +32
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

Copy link
Member

Choose a reason for hiding this comment

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

Since this is a new file, can you please fix the license header - you only need lines 1-7 as license header and not the remaining Elasticsearch license lines 9-31.

vinaykpud pushed a commit to vinaykpud/OpenSearch that referenced this pull request Sep 26, 2025
…ted metric in reducing aggregation (opensearch-project#18411)

* Making changes in InternalValueCount and InternalAvg to support Scripted metric in reducing agggregation

Signed-off-by: Kshitij Tandon <[email protected]>

* Adding tests for supporting Scripted Aggregation in reduce for average and value count aggregations

Signed-off-by: Kshitij Tandon <[email protected]>

* Fixing build issues

Signed-off-by: Kshitij Tandon <[email protected]>

* Addressed comments around logging and tests

Signed-off-by: Kshitij Tandon <[email protected]>

* Making changes to CHANGELOG.md

Signed-off-by: Kshitij Tandon <[email protected]>

* Adding a new class ScriptedAvg for reduce

Signed-off-by: Kshitij Tandon <[email protected]>

* Adding changes to CHANGELOG

Signed-off-by: Kshitij Tandon <[email protected]>

* Adding javadocs

Signed-off-by: Kshitij Tandon <[email protected]>

* Fixing violations

Signed-off-by: Kshitij Tandon <[email protected]>

---------

Signed-off-by: Kshitij Tandon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants