yujun777 opened a new pull request, #49457: URL: https://github.com/apache/doris/pull/49457
### What problem does this PR solve? This PR do two things: 1. Replace null to false for the filter plan. In filter condition, for a null literal, if all of its ancestors are AND / OR / NOT, then this null literal can replace to FALSE. for example, for sql `where a > 1 and a < 0 or b > 0`, simplify range rule will rewrite it to `where a is null and null or b > 0`, this condition is not pretty, it's an OR expression and contains the IS-NULL-AND-NULL. Notice `A IS NULL AND NULL` can never eval to TRUE. so we replace the NULL literal with FALSE, can we get `a is null and FALSE or b > 0`, then after fold constant, then we get `b > 0`, wow, this is a pretty condition and can push it down latter. 2. Adjust the expression optimization rule order, we move SimplifyRange ahead of ExtractCommonFactor. consider a sql `where a > 1 and b > 1 or a > 1 and a < 0`. Notice use SimplifyRange can rewrite 'a > 1 and a < 0' to FALSE. But if execute ExtractCommonFactor rule first, we will get `a > 1 and (b > 1 or a < 0)`, and break the `a > 1 and a < 0`, then we cann't simplify it. So we move SimplifyRange ahead of ExractCommonFactor, when execute SimplifyRange first, we will can `where a > 1 and b > 1 or (a is null and null)`, then we replace null to false, can get `where a > 1 and b > 1 or (a is null and FALSE)`, then after fold constant, we will get `where a > 1 and b > 1` ### 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