Steve Carlin has uploaded a new patch set (#2). ( 
http://gerrit.cloudera.org:8080/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.

The validator was changed to force a BIGINT return type for whatever
expression exists in the limit 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
---
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 
java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ImpalaSqlValidatorImpl.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
7 files changed, 179 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/68/24268/2
--
To view, visit http://gerrit.cloudera.org:8080/24268
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ic01a0144671485156654e7685d0d5816fa743f9d
Gerrit-Change-Number: 24268
Gerrit-PatchSet: 2
Gerrit-Owner: Steve Carlin <[email protected]>

Reply via email to