Steve Carlin has submitted this change and it was merged. ( https://gerrit.cloudera.org/25415 )
Change subject: IMPALA-15774: Decode SQL string escapes before Calcite simplification ...................................................................... IMPALA-15774: Decode SQL string escapes before Calcite simplification Calcite kept string literals in their SQL-escaped form and only unescaped them when building an Impala StringLiteral. Simplification and predicate inference compared that escape text, so '\061' and '1' folded the wrong way. LIKE patterns with an escaped wildcard had the same cause. Decode the literal in ImpalaRexBuilder while the plan is still being built from SQL, which is before postAnalysis_. Literals created after that are already decoded, so RexLiteralConverter no longer unescapes them and constant folding no longer doubles backslashes. Removed the line in ImpalaRexExecutor which added the escape character back into the RexLiteral after constant folding since the string in the RexLiteral is already unescaped. One exception that is handled. The date format string in the cast statement needs to retain its escape characters. Kudu, HBase, and data-source predicate pushdown also unescape a string again. That affects the original planner too. On master, select count(*) from functional_kudu.alltypestiny where string_col = concat(chr(92), '061') returns 4, while HDFS returns 0, because the folded value is unescaped a second time. Those paths now use unescapeIfNeeded(). Testing - CalciteEscapedStringLiteralTest, compared with the original planner. - Added the IMPALA-15774 cases to QueryTest/calcite.test. - QueryTest/string-escaping.test checks the Kudu predicate, including string_col = concat(chr(92), '061') under the Calcite planner. Assisted-by: Grok 4.7 (Cursor) Change-Id: I2f3e3d7c152fe43feea88a97f9b4c892bee4afa4 Reviewed-on: https://gerrit.cloudera.org/25415 Tested-by: Impala Public Jenkins <[email protected]> Reviewed-by: Steve Carlin <[email protected]> --- M fe/src/main/java/org/apache/impala/planner/DataSourceScanNode.java M fe/src/main/java/org/apache/impala/planner/HBaseScanNode.java M fe/src/main/java/org/apache/impala/planner/KuduScanNode.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexLiteralConverter.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaConvertletTable.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaRexBuilder.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaValuesRel.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java A java/calcite-planner/src/test/java/org/apache/impala/calcite/service/CalciteEscapedStringLiteralTest.java M testdata/workloads/functional-query/queries/QueryTest/calcite.test M testdata/workloads/functional-query/queries/QueryTest/string-escaping.test 11 files changed, 214 insertions(+), 12 deletions(-) Approvals: Impala Public Jenkins: Verified Steve Carlin: Looks good to me, approved -- To view, visit https://gerrit.cloudera.org/25415 To unsubscribe, visit https://gerrit.cloudera.org/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I2f3e3d7c152fe43feea88a97f9b4c892bee4afa4 Gerrit-Change-Number: 25415 Gerrit-PatchSet: 13 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: Steve Carlin <[email protected]> Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]>
