Steve Carlin has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24247 )
Change subject: IMPALA-14814: Handle implicit casts properly for Calcite Planner ...................................................................... IMPALA-14814: Handle implicit casts properly for Calcite Planner Previous to this commit, the Calcite planner overrode the isImplicit() method to prevent the framework from removing implicit casts. The reasoning behind this was because Calcite has already gone through the analysis phase and determined that a cast was necessary. The original planner combines the substitution of slot refs with the removal of implicit casts and then re-analyzes the Expr object. So Calcite needs to avoid this removal. On first pass, it seemed that removing any recognition of the existence of an implicit cast was an adequate solution. However, in certain cases, like the analysis of parquet stats, the physical planner needs to know if the cast is explicit or implicit. This commit now sets the isImplicit_ variable correctly in the AnalyzedCastExpr through the CastExpr constructor. The code within substituteImpl that removes the cast has been moved into the child CastExpr class. A new method, shouldRemoveImplicitCast(), will return the isImplicit() value for the CastExpr class but will always return false for the Calcite AnalyzedCastExpr class. In addition to this change, the "hashCode()" method is also used within the ExprSubstitutionMap so that code also needs to be avoided in the child AnalyzedCastExpr class. Change-Id: I4d71357ac7f228404713f96884d9eff7f8eabe5c Reviewed-on: http://gerrit.cloudera.org:8080/24247 Reviewed-by: Michael Smith <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> Reviewed-by: Steve Carlin <[email protected]> --- M fe/src/main/cup/sql-parser.cup M fe/src/main/java/org/apache/impala/analysis/AlterTableExecuteExpireSnapshotsStmt.java M fe/src/main/java/org/apache/impala/analysis/AlterTableExecuteRemoveOrphanFilesStmt.java M fe/src/main/java/org/apache/impala/analysis/AlterTableExecuteRollbackStmt.java M fe/src/main/java/org/apache/impala/analysis/BoolLiteral.java M fe/src/main/java/org/apache/impala/analysis/CastExpr.java M fe/src/main/java/org/apache/impala/analysis/ColumnDef.java M fe/src/main/java/org/apache/impala/analysis/ConstantPredicateHandler.java M fe/src/main/java/org/apache/impala/analysis/DateLiteral.java M fe/src/main/java/org/apache/impala/analysis/DescribeHistoryStmt.java M fe/src/main/java/org/apache/impala/analysis/Expr.java M fe/src/main/java/org/apache/impala/analysis/IcebergMergeQueryGenerator.java M fe/src/main/java/org/apache/impala/analysis/NumericLiteral.java M fe/src/main/java/org/apache/impala/analysis/RangePartition.java M fe/src/main/java/org/apache/impala/analysis/StatementBase.java M fe/src/main/java/org/apache/impala/analysis/StringLiteral.java M fe/src/main/java/org/apache/impala/analysis/TimeTravelSpec.java M fe/src/main/java/org/apache/impala/analysis/TimestampLiteral.java M fe/src/main/java/org/apache/impala/rewrite/RemoveRedundantStringCast.java M fe/src/main/java/org/apache/impala/rewrite/SimplifyCastStringToTimestamp.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/AnalyzedCastExpr.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/RexCallConverter.java M java/calcite-planner/src/test/java/org/apache/impala/calcite/planner/TestReduceExprShuttle.java M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q02.test M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q18.test M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q49.test M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q54.test M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q59.test M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q84.test M testdata/workloads/functional-planner/queries/PlannerTest/calcite_tpcds/tpcds-q90.test M testdata/workloads/functional-query/queries/QueryTest/calcite.test M testdata/workloads/functional-query/queries/QueryTest/orc-stats.test M testdata/workloads/functional-query/queries/QueryTest/parquet-stats.test 33 files changed, 229 insertions(+), 232 deletions(-) Approvals: Michael Smith: Looks good to me, but someone else must approve Impala Public Jenkins: Verified Steve Carlin: Looks good to me, approved -- To view, visit http://gerrit.cloudera.org:8080/24247 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I4d71357ac7f228404713f96884d9eff7f8eabe5c Gerrit-Change-Number: 24247 Gerrit-PatchSet: 12 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: Steve Carlin <[email protected]>
