Daniel Becker has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/17847


Change subject: IMPALA-10838: Error when struct returned from WITH()
......................................................................

IMPALA-10838: Error when struct returned from WITH()

The following query fails:
'''
with sub as (
    select id, outer_struct
    from functional_orc_def.complextypes_nested_structs)
select sub.id, sub.outer_struct.inner_struct2 from sub;
'''

with the following error:
'''
ERROR: IllegalStateException: Illegal reference to non-materialized
tuple: debugname=InlineViewRef sub alias=sub tid=6
'''

while if 'outer_struct.inner_struct2' is added to the select list of the
inline view, the query works as expected.

This change fixes the problem by two modifications:
  - if a field of a struct needs to be materialised, also materialise
    all of its enclosing structs (ancestors)
  - in expression substitutions (in
    org.apache.impala.analysis.Expr.substituteImpl), if there is no
    substitution mapping for a field of a struct but there is a mapping
    for an enclosing struct, find the mapping for that enclosing struct
    and from its subexpressions use the one corresponding to the
    original expression for substitution

Tests:
  - added queries that are fixed by this change (including the one
    above) in nested-struct-in-select-list.test

Change-Id: Iadb9233677355b85d424cc3f22b00b5a3bf61c57
---
M fe/src/main/java/org/apache/impala/analysis/Expr.java
M fe/src/main/java/org/apache/impala/analysis/ExprSubstitutionMap.java
M fe/src/main/java/org/apache/impala/analysis/Path.java
M fe/src/main/java/org/apache/impala/analysis/SlotRef.java
M 
testdata/workloads/functional-query/queries/QueryTest/nested-struct-in-select-list.test
5 files changed, 175 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/47/17847/3
--
To view, visit http://gerrit.cloudera.org:8080/17847
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iadb9233677355b85d424cc3f22b00b5a3bf61c57
Gerrit-Change-Number: 17847
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Becker <daniel.bec...@cloudera.com>
Gerrit-Reviewer: Csaba Ringhofer <csringho...@cloudera.com>
Gerrit-Reviewer: Gabor Kaszab <gaborkas...@cloudera.com>

Reply via email to