Steve Carlin has submitted this change and it was merged. ( https://gerrit.cloudera.org/24268 )
Change subject: IMPALA-14910: Calcite planner: support expressions in limit clause ...................................................................... IMPALA-14910: Calcite planner: support expressions in limit clause This commit contains changes to the Calcite planner which support expressions in the limit clause, e.g. "limit 1 + 1" The parser now has the capability of reading expressions in the clause. There are a few rules in Calcite which expect a RexLiteral to be in the "LogicalSort.fetch" and "LogicalSort.offset" fields. The reduction logic is therefore done before most rules are applied. If the expression is unable to be simplified to a RexLiteral, an exception will be thrown, but this is really no different from current behavior if the SQL contained something like "limit <col1>". The reduction logic for the expression is in the ImpalaSortSimplifyRule which is similar to the ImpalaFilterSimplifyRule (and Project and Join) The normal reduction logic tries to keep the RelDataType unchanged and adds a cast if necessary to do so. However, the expression in the limit cannot handle a cast or a change in nullability. So some logic was added to avoid this when the expression is in a limit clause. Change-Id: Ic01a0144671485156654e7685d0d5816fa743f9d Reviewed-on: https://gerrit.cloudera.org/24268 Reviewed-by: Michael Smith <[email protected]> Tested-by: Michael Smith <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- M java/calcite-planner/src/main/codegen/templates/Parser.jj M java/calcite-planner/src/main/java/org/apache/impala/calcite/coercenodes/CoerceNodes.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaRexExecutor.java A java/calcite-planner/src/main/java/org/apache/impala/calcite/rules/ImpalaSortSimplifyRule.java M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteOptimizer.java M testdata/workloads/functional-query/queries/QueryTest/calcite.test M testdata/workloads/functional-query/queries/QueryTest/calcite_subquery.test 7 files changed, 258 insertions(+), 32 deletions(-) Approvals: Michael Smith: Looks good to me, approved; Verified Impala Public Jenkins: Verified -- To view, visit https://gerrit.cloudera.org/24268 To unsubscribe, visit https://gerrit.cloudera.org/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Ic01a0144671485156654e7685d0d5816fa743f9d Gerrit-Change-Number: 24268 Gerrit-PatchSet: 12 Gerrit-Owner: Steve Carlin <[email protected]> Gerrit-Reviewer: Aleksandr Efimov <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Steve Carlin <[email protected]>
