You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Quanlong Huang (Jira)" <ji...@apache.org> on 2020/06/09 06:12:00 UTC

[jira] [Assigned] (IMPALA-9694) IllegalStateException when inlineView has AggregationNode and different alias on the same column

     [ https://issues.apache.org/jira/browse/IMPALA-9694?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Quanlong Huang reassigned IMPALA-9694:
--------------------------------------

    Assignee: Quanlong Huang

> IllegalStateException when inlineView has AggregationNode and different alias on the same column
> ------------------------------------------------------------------------------------------------
>
>                 Key: IMPALA-9694
>                 URL: https://issues.apache.org/jira/browse/IMPALA-9694
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>            Reporter: Quanlong Huang
>            Assignee: Quanlong Huang
>            Priority: Critical
>              Labels: ramp-up
>
> The following query fails with IllegalStateException:
> {code:sql}
> > create table t1(ts TIMESTAMP, id BIGINT);
> > select count(*) from (
>     select lead(ts) over (partition by id order by ts),
>            id foo,
>            id bar
>     from t1
>   ) v;
> ERROR: IllegalStateException: Illegal reference to non-materialized slot: tid=0 sid=1
> {code}
> The query works without the PartitionBy clause:
> {code:sql}
> select count(*) from (
>   select lead(ts) over (order by ts),
>          id foo,
>          id bar
>   from t1
> ) v;
> {code}
> Or avoid different alias on the same column:
> {code:sql}
> select count(*) from (
>   select lead(ts) over (partition by id order by ts),
>          id foo
>   from t1
> ) v;
> {code}
> *Clues*
>  Enabling TRACE level logging of the coordinator and rerun the failed query, the illegal predicate "v.foo = v.bar" shows up:
> {code:java}
> I0426 20:10:10.194453  1068 Analyzer.java:2143] 4241809b91bf54de:d5365a1700000000] Created inferred predicate: BinaryPredicate{op==, SlotRef{label=v.foo, type=BIGINT, id=4} SlotRef{label=v.bar, type=BIGINT, id=5}, isInferred=true}
> I0426 20:10:10.194509  1068 Analyzer.java:2574] 4241809b91bf54de:d5365a1700000000] Assigned BinaryPredicate{op==, SlotRef{label=v.foo, type=BIGINT, id=4} SlotRef{label=v.bar, type=BIGINT, id=5}, isInferred=true}
> {code}
> It's finally migrated into the inlineView and references to "t1.id" which is non-materialized. The planner generates this predicate since there are two auxiliary predicates "v.foo = t1.id", "v.bar = t1.id". These two auxiliary predicates only occur when the AggregationNode exists. We need to look deeper into this bug.
> *Workaround*
>  Replace the second occurrence of the reference column with an identity expression, e.g. change the above-failed query to:
> {code:sql}
> select count(*) from (
>   select lead(ts) over (partition by id order by ts),
>          id foo,
>          id - 1 + 1 as bar
>   from t1
> ) v;
> {code}
> By replacing the second occurrence of "id" to "id- 1 + 1", the planner can't detect that the equivalence between "v.foo" and "v.bar". So the AggregationNode won't have the redundant predicate "v.foo = v.bar" and won't have illegal reference to "t1.id".



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org