Repository navigation
Conversation
A field mapped as two different numeric types across the indices of one wildcard fell through to LatestRule, which keeps the mapping of whichever index the merge reads last. That read order can differ between nodes and after a restart, so the merged type changed with it. When an integer type won, a float value came back null. A narrower integer type wrapped a wider value, and a float type rounded a long above 2^24. Add NumericWideningRule ahead of LatestRule. Two integer types merge to the wider one, half_float and float merge to float, and any other numeric pair merges to double. The merged type then no longer depends on read order, and only a long beyond 2^53 next to a floating point type loses precision. The PPL limitations page now names the eight numeric types as an exception to the type picked from one index. Signed-off-by: Chayanin Noramuttha <cnoramut@amazon.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (75.21%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #5902 +/- ##
============================================
+ Coverage 75.19% 75.21% +0.01%
- Complexity 10362 10385 +23
============================================
Files 962 963 +1
Lines 41098 41123 +25
Branches 4683 4689 +6
============================================
+ Hits 30905 30932 +27
+ Misses 8896 8895 -1
+ Partials 1297 1296 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
When the indices behind one source map a field to two different number types, the plugin keeps the type of whichever index the merge reads last, and that order can change between nodes and after a restart. Under the wrong winner a value changes or comes back null with HTTP 200, so a
long5000000000read asintegerreturns705032704.fin index 0fin index 1mainfields flong5000000000integer3intlong5000000000integer3bigintdouble1.5long5bigintdouble1.5long5doublelong16777217half_float1.5floatlong16777217half_float1.5bigintFix. A new
NumericWideningRuleruns ahead ofLatestRuleinMergeRuleHelperand merges a numeric conflict to one type, whatever the read order. Two integer types merge to the wider one,half_floatandfloatmerge tofloat, and any other numeric pair merges todouble. The PPL limitations page now states the same rule.Each pair gave one merged type across 12 index name prefixes. Twelve indices covering all eight number types also merged to
double, and twelve integer indices tobigint, under five index name prefixes each.fin index 0fin index 1fields flong5000000000integer3bigintdouble1.5long5doublelong16777217half_float1.5doubleNotes, as mentioned in #5901
floatgivesdouble- Core'sWideningTypeRulewould pickfloat, and afloatholds integers exactly only up to 2^24, so16777217would read16777216.0. The cost is that an integer row next to a floating point index renders as a double, so3reads3.0. A pushedminover afloatindex also prints0.1as0.10000000149011612, the stored float's exact value.LatestRule- A number against a string ordatetype, and analiasof a number field, keep today's behaviour.Related Issues
Part of #5828 - This fixes the number against number rows. Its other rows, such as
longagainstdate, are unchanged, so this PR does not resolve it.Resolves #5901
Testing
NumericWideningRuleTest, 13 cases that merge throughMergeRuleHelperin both orders, plus three type sets in all six orders. Taking the rule out ofRULESfails 6 of them, and makinghalf_floatwithfloatreturndoublefails 2.issues/5901.yml, 3 cases. The first spansbyte,short,integerandlong, the others pairlongwithdoubleand withhalf_float. Each asserts the schema type and the values. With the rule taken out ofRULES, the first and third failed on the type, reportingintandfloat. Thelongwithhalf_floatcase always fails without the rule, since its expecteddoubleis a type neither index holds. The other two fail only when a narrower index is read last, which depends on the index names in each JVM, so thelongwithdoublecase passed in that run.:opensearch:testran 1835 tests with 0 failures.mainmainat31eea45a8, about 100 templatesmainatf36c99f84mainatf36c99f84The SQL results improved where
mainread floating point values as null, read ashort300as44undertinyint, or cut a pushedMAXto an integer. The Calcite sweep changed no single-index result.Check List
--signoffor-s.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.