starocean999 opened a new pull request, #67154:
URL: https://github.com/apache/doris/pull/67154

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   Nereids' default DECIMALV3 precision promotion
   (`ComputeSignatureHelper.defaultDecimalV3PrecisionPromotion`) recursively 
collects every
   DECIMALV3 found in the argument types, computes a single global "wider" 
type, and then
   replaces ALL decimal slots with that one type via
   `TypeCoercionUtils.replaceDecimalV3WithTarget`.
   
   For `MAP<K, V>` where K and V are independent type variables with different
   precision/scale, merging them into one wider type breaks correctness in two 
ways
   (they share the same type-derivation path):
   
   1. `MAP_KEYS` (and other map consumers) silently turns legal keys into NULL.
      Repro: a `MAP<DECIMAL(76,0), DECIMAL(76,18)>` built from a 76-digit 
integral key
      and `0.125000000000000000`. Widening the key slot to scale 18 overflows 
the big
      integral key, so `MAP_KEYS` returns `[null]` instead of the key.
   2. `UNNEST(MAP)` (rewritten to `EXPLODE_MAP`) fails type analysis. The 
promoted MAP
      argument type no longer matches the original input MAP type.
   
   Fix: promote each decimal slot independently instead of merging them. Each 
slot
   (MAP key/value, ARRAY item, scalar) keeps its own precision/scale derived 
from its
   own argument type; the wider type is only used for NULL-typed slots and the
   placeholder return type. Vararg slots keep the previous behavior to avoid 
changing
   vararg decimal functions (e.g. `field`).
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to