yujun777 opened a new pull request, #46303: URL: https://github.com/apache/doris/pull/46303
### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: For range inference, it will merge multiple value desc whose reference are the same. It will merge two value desc. Diff merge order may get diff result. For range reference: `x1 op x2 op x3 op x4` If op is `AND`, then the merge order doesn't matter. It will always get the same result. But if op is 'OR', then the merge order does matter. For example: (a < 10) or ( a > 30) or (a >= 15 and a <= 35). When merge the first OP, it will get an UnknownValue: and its source is: [ (-00, 10), (30, +00) ], latter will merge this UnknowValue with RangeValue [15, 35]. Since UnknowValue union another value desc will get a new UnknownValue, then then final result is UknownValue(UnknowValue(RangeValue(a<10) or RangeValue(a>30)) or RangeValue(a>=15 and a <= 35)). This is bad. It should merge the 1st and 3rd value desc firstly, latter merge the 2nd value desc, Then finally the merge result is 'TRUE'. In order to achieve this, use a RangeSet to record all the ranges, then RangeSet will auto merge the results. What's more, this pr also: 1. opt 'a > 20 or a = 20' to 'a >= 20'; 2. for the discrete value's options, if an option is in one range, then the option will eliminate. for example: `a <= 10 or a in [1, 2, 3, 11, 12, 13]` will opt to `a <= 10 or a in [11, 12, 13]` ### 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org