Quanlong Huang created IMPALA-15591:
---------------------------------------
Summary: Consolidate AnalyticEvalNodes in the same stack
Key: IMPALA-15591
URL: https://issues.apache.org/jira/browse/IMPALA-15591
Project: IMPALA
Issue Type: Improvement
Reporter: Quanlong Huang
The following query has 2 AnalyticEvalNodes:
{code:sql}
EXPLAIN select id,
rank() over (partition by bigint_col, int_col order by id),
rank() over (partition by bigint_col order by id)
from functional.alltypes where year = 2009;{code}
The query plan:
{noformat}
PLAN-ROOT SINK
|
06:EXCHANGE [UNPARTITIONED]
|
04:ANALYTIC
| functions: rank()
| partition by: bigint_col
| order by: id ASC
| window: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
| row-size=36B cardinality=3.65K
|
03:SORT
| order by: bigint_col ASC NULLS LAST, id ASC
| row-size=28B cardinality=3.65K
|
02:ANALYTIC
| functions: rank()
| partition by: bigint_col, int_col
| order by: id ASC
| window: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
| row-size=28B cardinality=3.65K
|
01:SORT
| order by: bigint_col ASC NULLS LAST, int_col ASC NULLS LAST, id ASC
| row-size=20B cardinality=3.65K
|
05:EXCHANGE [HASH(bigint_col)]
|
00:SCAN HDFS [functional.alltypes]
partition predicates: `year` = 2009
HDFS partitions=12/24 files=12 size=238.68KB
row-size=20B cardinality=3.65K{noformat}
Reordering the analytic functions in the query also reorders the
AnalyticEvalNode in the plan:
{code:sql}
EXPLAIN select id,
rank() over (partition by bigint_col order by id),
rank() over (partition by bigint_col, int_col order by id)
from functional.alltypes where year = 2009;{code}
Query plan:
{noformat}
PLAN-ROOT SINK
|
06:EXCHANGE [UNPARTITIONED]
|
04:ANALYTIC
| functions: rank()
| partition by: bigint_col, int_col
| order by: id ASC
| window: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
| row-size=36B cardinality=3.65K
|
03:SORT
| order by: bigint_col ASC NULLS LAST, int_col ASC NULLS LAST, id ASC
| row-size=28B cardinality=3.65K
|
02:ANALYTIC
| functions: rank()
| partition by: bigint_col
| order by: id ASC
| window: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
| row-size=28B cardinality=3.65K
|
01:SORT
| order by: bigint_col ASC NULLS LAST, id ASC
| row-size=20B cardinality=3.65K
|
05:EXCHANGE [HASH(bigint_col)]
|
00:SCAN HDFS [functional.alltypes]
partition predicates: `year` = 2009
HDFS partitions=12/24 files=12 size=238.68KB
row-size=20B cardinality=3.65K{noformat}
In HBO key string of AnalyticEvalNode, the order decides which one is the child
node. This shouldn't matter since these two queries are identical. We should
consider consolidating the AnalyticEvalNodes in the same stack into one,
similar to what we done for continuous INNER JOINs.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)