← Back to Pull requests

Widen numeric mapping conflicts to one deterministic type #5902

Closed
unknown closed this pull request without merging on Oct 22, 2026 18:30 UTC
View on GitHub
unknown unknown commented on Oct 21, 2026 03:58 UTC
Author

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 long 5000000000 read as integer returns 705032704.

| f in index 0 | f in index 1 | merged type on main | fields f |
| --- | --- | --- | --- |
| long 5000000000 | integer 3 | int | 705032704, 3 |
| long 5000000000 | integer 3 | bigint | 5000000000, 3 |
| double 1.5 | long 5 | bigint | null, 5 |
| double 1.5 | long 5 | double | 1.5, 5.0 |
| long 16777217 | half_float 1.5 | float | 16777216.0, 1.5 |
| long 16777217 | half_float 1.5 | bigint | 16777217, null |

Fix. A new NumericWideningRule runs ahead of LatestRule in MergeRuleHelper and merges a numeric conflict to one type, whatever the read order. Two integer types merge to the wider one, half_float and float merge to float, and any other numeric pair merges to double. 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 to bigint, under five index name prefixes each.

| f in index 0 | f in index 1 | merged type with the rule | fields f |
| --- | --- | --- | --- |
| long 5000000000 | integer 3 | bigint | 5000000000, 3 |
| double 1.5 | long 5 | double | 1.5, 5.0 |
| long 16777217 | half_float 1.5 | double | 16777217.0, 1.5 |

Notes, as mentioned in #5901

1. Why an integer with float gives double - Core's WideningTypeRule would pick float, and a float holds integers exactly only up to 2^24, so 16777217 would read 16777216.0. The cost is that an integer row next to a floating point index renders as a double, so 3 reads 3.0. A pushed min over a float index also prints 0.1 as 0.10000000149011612, the stored float's exact value.
2. What still reaches LatestRule - A number against a string or date type, and an alias of a number field, keep today's behaviour.

Related Issues

Part of #5828 - This fixes the number against number rows. Its other rows, such as long against date, are unchanged, so this PR does not resolve it.
Resolves #5901

Testing

  • NumericWideningRuleTest, 13 cases that merge through MergeRuleHelper in both orders, plus three type sets in all six orders. Taking the rule out of RULES fails 6 of them, and making half_float with float return double fails 2.

  • issues/5901.yml, 3 cases. The first spans byte, short, integer and long, the others pair long with double and with half_float. Each asserts the schema type and the values. With the rule taken out of RULES, the first and third failed on the type, reporting int and float. The long with half_float case always fails without the rule, since its expected double is 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 the long with double case passed in that run.

  • :opensearch:test ran 1835 tests with 0 failures.

  • Each engine was measured on all 28 number pairs in both read orders.
  • | Engine | Result against main |
    | --- | --- |
    | PPL on Calcite, the rule alone against main at 31eea45a8, about 100 templates | results that depend on read order fell from 1,627 of 5,768 to 0, 108 errors became a 200, and none got worse |
    | PPL on V2, the same sweep with Calcite off, against main at f36c99f84 | none worse |
    | SQL, 50 queries and 1,400 results, against main at f36c99f84 | none worse, and 558 improved |

    The SQL results improved where main read floating point values as null, read a short 300 as 44 under tinyint, or cut a pushed MAX to an integer. The Calcite sweep changed no single-index result.

    Check List


  • New functionality includes testing.

  • New functionality has been documented.

  • - [x] New functionality has javadoc added.
    - [x] New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.

  • API changes companion pull request created.

  • Commits are signed per the DCO using --signoff or -s.

  • Public documentation issue/PR created.
  • 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.

    Diff: 640 lines (+480 / -160) across 8 files Reviewer: Swiddis Review duration: 2312m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 640 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.387
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5902"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 51.9% (MEDIUM) · Higher = larger blast radius
    51.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%