yujun777 commented on code in PR #49457: URL: https://github.com/apache/doris/pull/49457#discussion_r2052213546
########## fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/ExpressionRewriteSqlTest.java: ########## @@ -44,4 +43,44 @@ public void testExtractNonConstant() { "OR[id#0 IN (10, 20, 30, 300),(id#0 = score#1),(id#0 = (score#1 + 10)),(id#0 = (score#1 + score#1))]" ))); } + + @Test + public void testSimplifyRangeAndExtractCommonFactor() { + String sql = "select * from T1 where id > 1 and score > 1 or id > 1 and score > 10"; + PlanChecker.from(connectContext) + .analyze(sql) + .rewrite() + .matches( + logicalFilter().when(f -> f.getPredicate().toString().equals( + "AND[(id#0 > 1),(score#1 > 1)]" + ))); + + sql = "select * from T1 where id > 1 and score > 1 or id > 1 and id < 0"; + PlanChecker.from(connectContext) + .analyze(sql) + .rewrite() + .matches( + logicalFilter().when(f -> f.getPredicate().toString().equals( + "AND[(score#1 > 1),(id#0 > 1)]" Review Comment: updated -- 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