Steve Carlin has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/23731


Change subject: IMPALA-14422: Calcite planner: Crash on Union above Values 
RelNode
......................................................................

IMPALA-14422: Calcite planner: Crash on Union above Values RelNode

In version 1.37, for the query:

select 1 union all select count(*) ...

Calcite was creating the following RelNode structure:

LogicalUnion
  LogicalValues (1)
  LogicalAggregate
    ...

Calcite changed the behavior in 1.40 to ensure that all datatypes are matching.
Now it produces:

LogicalUnion
  LogicalProject(CAST 1 as SMALLINT)
   LogicalValues
  LogicalProject(CAST 5000 as SMALLINT)
    LogicalAggregate

The introduction of the Project between Values exposed a bug in the
ImpalaValuesRel class. The Values node was not looking at its parent
type in the situation where the parent was a Project and the tuple size
was 1.

The code in this commit also handles projects which ignore the values
underneath. When the "trivial" query is found, it creates the Plan Node
at the Project level rather than the Values level.

One other small change is thrown into this commit. The memory allocation
in the tuple descriptor was including a byte for nulls even when the
column was non-null. This has been fixed.

The testing for this is already included in calcite.test. This will fail
on a simple "select length('hello')" query, but only after upgrading to
at least Calcite 1.40.  So this commit is necessary before upgrading,
but no additional test is needed.

Change-Id: I1edf2f0bdb9271b5b8c9716ca7d8c8f858cc108c
---
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/rel/node/ImpalaProjectRel.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/rel/util/TupleDescriptorFactory.java
3 files changed, 79 insertions(+), 23 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/31/23731/1
--
To view, visit http://gerrit.cloudera.org:8080/23731
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1edf2f0bdb9271b5b8c9716ca7d8c8f858cc108c
Gerrit-Change-Number: 23731
Gerrit-PatchSet: 1
Gerrit-Owner: Steve Carlin <[email protected]>

Reply via email to