Zoltan Borok-Nagy has posted comments on this change. ( https://gerrit.cloudera.org/25395 )
Change subject: IMPALA-15753: Calcite Planner: Skip simplification for LIKE '\%%' ...................................................................... Patch Set 1: (4 comments) Thanks for working on this! Checked with Opus 5.5 as well. https://gerrit.cloudera.org/#/c/25395/1//COMMIT_MSG Commit Message: https://gerrit.cloudera.org/#/c/25395/1//COMMIT_MSG@17 PS1, Line 17: fix belongs in Calcite (CALCITE-7925); this workaround stays narrow Calcite is right for the pattern Impala means (it leaves a\%% unchanged). The problem is that the RexLiteral still holds the SQL-escaped 'a\\%%'. The same breaks other folding: 'a\q' = 'aq' is true in the original planner, false in Calcite. So the general fix looks like unescaping literals in the planner. Filed IMPALA-15774. https://gerrit.cloudera.org/#/c/25395/1/java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaRexSimplify.java File java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaRexSimplify.java: https://gerrit.cloudera.org/#/c/25395/1/java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaRexSimplify.java@63 PS1, Line 63: if (hasLikeEscapedWildcardIssue(rexNode)) { Predicates that Calcite infers itself still get simplified. RelMdPredicates uses a plain RexSimplify, so for a JOIN b ON a.s = b.s WHERE a.s LIKE 'a\\%%' it pushes b.s LIKE 'a\\%' to b. Could you handle this and add a join test? https://gerrit.cloudera.org/#/c/25395/1/java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaRexSimplify.java@122 PS1, Line 122: if (value != null && value.contains("\\%%")) { This misses other patterns where Calcite moves an escaped '%'. It also reorders '%_' to '_%', so 'a%b' LIKE 'a\\%_' is true in the original planner but false in Calcite. The same happens with an octal backslash: 'a%b' LIKE 'a\134%_'. How about skipping whenever the pattern contains a backslash? https://gerrit.cloudera.org/#/c/25395/1/testdata/workloads/functional-query/queries/QueryTest/calcite.test File testdata/workloads/functional-query/queries/QueryTest/calcite.test: https://gerrit.cloudera.org/#/c/25395/1/testdata/workloads/functional-query/queries/QueryTest/calcite.test@1662 PS1, Line 1662: ---- RESULTS : false,true,false,true,true,false FYI: CR 25198 (IMPALA-15641) fixes the BE fast path that gives true/true/false here. After it these become false/false/true, which unfixed Calcite also returns. Could you add 'a%x' LIKE 'a\\%%' (true after 25198) and a case over table rows: select count(*) from functional.alltypestiny where concat('a%', string_col) like 'a\\%_'; It returns 8 with the original planner and 0 with Calcite today; it needs the broader backslash check. Whichever of 25198 and 25395 lands second updates the expectations. -- To view, visit https://gerrit.cloudera.org/25395 To unsubscribe, visit https://gerrit.cloudera.org/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I7c7b99016dcaceb4c792eeb81499de4e2c8bd91b Gerrit-Change-Number: 25395 Gerrit-PatchSet: 1 Gerrit-Owner: Steve Carlin <[email protected]> Gerrit-Reviewer: Aman Sinha <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Joe McDonnell <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Quanlong Huang <[email protected]> Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]> Gerrit-Comment-Date: Tue, 10 Nov 2026 17:25:49 +0000 Gerrit-HasComments: Yes
