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

   
   simplify range have exception:
   
   ```
   mysql >  explain select pk from 
table_0_500_undef_partitions2_keys3_properties4_distributed_by5 where  not ( 
date_sub(col_date_undef_signed, interval 1 day) > '2010-03-21' or null ) or 
lower(col_varchar_20__undef_signed) between null and 'e';
   (1105, "errCode = 2, detailMessage = Cannot compare two values with 
different data types: 2010-03-22 (DATEV2) vs 'e' (VARCHAR(1))")
   ```
   
   PR #57537  introduce  merging compound value with other value desc.
   
   when merge value desc, it will merge values with the same reference.
   
   but for compound value,  its reference have other meaning:
   1) a < 1 or a > 10,  this is a compound value,  its reference is a;
   2) a < 1 or b > 10,  this is a compound value,  its reference is 'a < 1 or b 
> 10'.
   
   then for expression  `TA > 1 and FALSE  or FALSE and SB > 'abc''`,  for the 
operator OR,  it will have two compound values:
   a.  C1 = CompoundValue(referece = getCompoundValue(TA > 1 and FALSE) = 
FALSE,   source values={TA > 1,  FALSE})
   b.  C2 = CompoundValue(reference = getCompoundValue(FALSE and SB > 'abc') = 
FALSE, source values={FALSE, SB > 'abc'})
   
   because the function getCompoundValue will fold constant,  then C1 andC2's 
referece will be 'FALSE', and since C1 and C2's reference equals, then will try 
merge C1 and C2,  then will check merge ' >  1'  and ' > abc'  will cause the 
above exception.
   
   to fix this,  for a compound value if its source values different reference 
(like a < 1 or b > 10), then don't merge it with other values descs.
   
   ### Release note
   
   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