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

fix: correct decimal detection in range filtering issue#17247 #17372

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DanielSEncora
Copy link

Description

Previously, hasDecimalPart(parsedLow) and hasDecimalPart(parsedHigh) were used after converting values to Long, causing loss of decimal precision and incorrect range adjustments.

Now, hasDecimalPart(rawLow) and hasDecimalPart(rawHigh) are used instead, ensuring proper detection before conversion and preventing off-by-one errors in range filters.

Related Issues

Resolves #17247

Check List

  • Functionality includes testing. (Working on them...)

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.

Previously, hasDecimalPart(parsedLow) and hasDecimalPart(parsedHigh) were used after converting values to Long, causing loss of decimal precision and incorrect range adjustments.

Now, hasDecimalPart(rawLow) and hasDecimalPart(rawHigh) are used instead, ensuring proper detection before conversion and preventing off-by-one errors in range filters.

Signed-off-by: Daniel Salas <[email protected]>
Copy link
Contributor

❕ Gradle check result for 3791e74: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.44%. Comparing base (2d2b41d) to head (3791e74).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17372      +/-   ##
============================================
+ Coverage     72.34%   72.44%   +0.10%     
- Complexity    65480    65552      +72     
============================================
  Files          5291     5291              
  Lines        304313   304318       +5     
  Branches      44176    44176              
============================================
+ Hits         220142   220453     +311     
+ Misses        66133    65767     -366     
- Partials      18038    18098      +60     

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

@expani
Copy link
Contributor

expani commented Feb 18, 2025

Thanks for opening the PR @DanielSEncora

Please add a UT under org.opensearch.search.aggregations.startree.MetricAggregatorTests#testStarTreeDocValues which will fail on the absence of this fix.

…ecimals validates the behavior of the StarTree index when it works with decimal values (both double and float types). testStarTreeDocValuesDecimalPrecision validates that the StarTree index maintains decimal precision, particularly with high precision values like 10.9999 for double and 99.999f for float.

Signed-off-by: Daniel Salas <[email protected]>
@DanielSEncora
Copy link
Author

Hi @expani, the requested UTs have been added! Let me know if any other changes need to be made.

Copy link
Contributor

❌ Gradle check result for 264a58c: 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?

@@ -168,6 +168,47 @@ public void testStarTreeDocValues() throws IOException {
}
}

public void testStarTreeDocValuesWithDecimals() throws IOException {
final List<DimensionFieldData> dimensionFieldDatum = List.of(
new DimensionFieldData("double_field", () -> 10.75, DimensionTypes.DOUBLE),
Copy link
Contributor

Choose a reason for hiding this comment

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

We can generate a random float having precision and change it to int_field and long_field essentially non-decimal numeric fields.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @expani , my apologies. Could you elaborate on what changes should be made to my contribution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Search Search query, autocomplete ...etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Use rawLow/rawHigh instead of parsedLow/parsedHigh in function - hasDecimalPart()
2 participants