-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-24167: TPC-DS query 14 fails while generating plan for the filter #5077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
b23ec31
50dc3f3
17cea96
3cfb6e1
c473fe9
b11e3f8
bd22d94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| import org.apache.hadoop.hive.ql.optimizer.calcite.HiveRelShuttle; | ||
| import org.apache.hadoop.hive.ql.optimizer.calcite.RelOptHiveTable; | ||
| import org.apache.hadoop.hive.ql.optimizer.calcite.TraitsUtil; | ||
| import org.apache.hadoop.hive.ql.optimizer.signature.RelTreeSignature.RelTreeSignatureWriter; | ||
| import org.apache.hadoop.hive.ql.plan.ColStatistics; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
|
|
@@ -202,6 +203,12 @@ public HiveTableScan copyIncludingTable(RelDataType newRowtype) { | |
| // Also include partition list key to trigger cost evaluation even if an | ||
| // expression was already generated. | ||
| @Override public RelWriter explainTerms(RelWriter pw) { | ||
| if (pw instanceof RelTreeSignatureWriter) { | ||
| return super.explainTerms(pw) | ||
| .item("tableScanTrait", this.tableScanTrait) | ||
| .itemIf("fromVersion", ((RelOptHiveTable) table).getHiveTableMD().getVersionIntervalFrom(), | ||
| isNotBlank(((RelOptHiveTable) table).getHiveTableMD().getVersionIntervalFrom())); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some attributes that could differentiate two HiveTableScans. We may not need these ones here. There is one potential problem in my mind. HiveTableScan doesn't retain the equivalents of |
||
| } | ||
| return super.explainTerms(pw) | ||
| .itemIf("qbid:alias", concatQbIDAlias, this.useQBIdInDigest) | ||
| .itemIf("htColumns", this.neededColIndxsFrmReloptHT, pw.getDetailLevel() == SqlExplainLevel.DIGEST_ATTRIBUTES) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,8 +277,8 @@ private ASTNode convert() throws CalciteSemanticException { | |
| if (where != null) { | ||
| ASTNode cond = where.getCondition().accept(new RexVisitor(schema, false, root.getCluster().getRexBuilder())); | ||
| hiveAST.where = ASTBuilder.where(cond); | ||
| planMapper.link(cond, where); | ||
| planMapper.link(cond, RelTreeSignature.of(where)); | ||
| planMapper.link(cond, where); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We link RelTreeSignature first so that we can safely unify multiple filters.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool! :D |
||
| } | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --! qt:dataset:src | ||
|
|
||
| set hive.optimize.cte.materialize.threshold=1; | ||
| set hive.optimize.cte.materialize.full.aggregate.only=false; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By setting this property the test fails with the same
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm checking the whole execution and what the flag does. Disabling I'm putting my additional notes here. I tried to put some to-be solutions but it could not be very easy.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found this fails if we disable @zabetak As a potential workaround, I'm wondering if it makes sense to relax the validation and disable features with which PlanMapper is involved when "equivalence mapping violation" happens. |
||
|
|
||
| EXPLAIN CBO | ||
| WITH materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ), | ||
| another_materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ) | ||
| SELECT a.key, a.value, b.key, b.value | ||
| FROM materialized_cte a | ||
| JOIN another_materialized_cte b ON a.key = b.key | ||
| ORDER BY a.key; | ||
|
|
||
| EXPLAIN | ||
| WITH materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ), | ||
| another_materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ) | ||
| SELECT a.key, a.value, b.key, b.value | ||
| FROM materialized_cte a | ||
| JOIN another_materialized_cte b ON a.key = b.key | ||
| ORDER BY a.key; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,246 @@ | ||
| PREHOOK: query: EXPLAIN CBO | ||
| WITH materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ), | ||
| another_materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ) | ||
| SELECT a.key, a.value, b.key, b.value | ||
| FROM materialized_cte a | ||
| JOIN another_materialized_cte b ON a.key = b.key | ||
| ORDER BY a.key | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@another_materialized_cte | ||
| PREHOOK: Input: default@materialized_cte | ||
| #### A masked pattern was here #### | ||
| POSTHOOK: query: EXPLAIN CBO | ||
| WITH materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ), | ||
| another_materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ) | ||
| SELECT a.key, a.value, b.key, b.value | ||
| FROM materialized_cte a | ||
| JOIN another_materialized_cte b ON a.key = b.key | ||
| ORDER BY a.key | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@another_materialized_cte | ||
| POSTHOOK: Input: default@materialized_cte | ||
| #### A masked pattern was here #### | ||
| CBO PLAN: | ||
| HiveSortLimit(sort0=[$0], dir0=[ASC]) | ||
| HiveProject(key=[$0], value=[$1], key0=[$2], value0=[$3]) | ||
| HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available]) | ||
| HiveProject(key=[$0], value=[$1]) | ||
| HiveFilter(condition=[IS NOT NULL($0)]) | ||
| HiveTableScan(table=[[default, materialized_cte]], table:alias=[a]) | ||
| HiveProject(key=[$0], value=[$1]) | ||
| HiveFilter(condition=[IS NOT NULL($0)]) | ||
| HiveTableScan(table=[[default, another_materialized_cte]], table:alias=[b]) | ||
|
|
||
| PREHOOK: query: EXPLAIN | ||
| WITH materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ), | ||
| another_materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ) | ||
| SELECT a.key, a.value, b.key, b.value | ||
| FROM materialized_cte a | ||
| JOIN another_materialized_cte b ON a.key = b.key | ||
| ORDER BY a.key | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@another_materialized_cte | ||
| PREHOOK: Input: default@materialized_cte | ||
| #### A masked pattern was here #### | ||
| POSTHOOK: query: EXPLAIN | ||
| WITH materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ), | ||
| another_materialized_cte AS ( | ||
| SELECT key, value FROM src WHERE key != '100' | ||
| ) | ||
| SELECT a.key, a.value, b.key, b.value | ||
| FROM materialized_cte a | ||
| JOIN another_materialized_cte b ON a.key = b.key | ||
| ORDER BY a.key | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@another_materialized_cte | ||
| POSTHOOK: Input: default@materialized_cte | ||
| #### A masked pattern was here #### | ||
| STAGE DEPENDENCIES: | ||
| Stage-1 is a root stage | ||
| Stage-2 depends on stages: Stage-1 | ||
| Stage-7 depends on stages: Stage-2, Stage-0, Stage-5, Stage-3 | ||
| Stage-0 depends on stages: Stage-1 | ||
| Stage-4 is a root stage | ||
| Stage-5 depends on stages: Stage-4 | ||
| Stage-3 depends on stages: Stage-4 | ||
| Stage-6 depends on stages: Stage-7 | ||
|
|
||
| STAGE PLANS: | ||
| Stage: Stage-1 | ||
| Tez | ||
| #### A masked pattern was here #### | ||
| Vertices: | ||
| Map 1 | ||
| Map Operator Tree: | ||
| TableScan | ||
| alias: src | ||
| filterExpr: (key <> '100') (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Filter Operator | ||
| predicate: (key <> '100') (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: key (type: string), value (type: string) | ||
| outputColumnNames: _col0, _col1 | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| File Output Operator | ||
| compressed: false | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| table: | ||
| input format: org.apache.hadoop.mapred.TextInputFormat | ||
| output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | ||
| serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | ||
| name: default.materialized_cte | ||
| Execution mode: vectorized, llap | ||
| LLAP IO: all inputs | ||
|
|
||
| Stage: Stage-2 | ||
| Dependency Collection | ||
|
|
||
| Stage: Stage-7 | ||
| Tez | ||
| #### A masked pattern was here #### | ||
| Edges: | ||
| Reducer 4 <- Map 3 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE) | ||
| Reducer 5 <- Reducer 4 (SIMPLE_EDGE) | ||
| #### A masked pattern was here #### | ||
| Vertices: | ||
| Map 3 | ||
| Map Operator Tree: | ||
| TableScan | ||
| alias: a | ||
| filterExpr: key is not null (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Filter Operator | ||
| predicate: key is not null (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: key (type: string), value (type: string) | ||
| outputColumnNames: _col0, _col1 | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Reduce Output Operator | ||
| key expressions: _col0 (type: string) | ||
| null sort order: z | ||
| sort order: + | ||
| Map-reduce partition columns: _col0 (type: string) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| value expressions: _col1 (type: string) | ||
| Execution mode: vectorized, llap | ||
| LLAP IO: all inputs | ||
| Map 6 | ||
| Map Operator Tree: | ||
| TableScan | ||
| alias: b | ||
| filterExpr: key is not null (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Filter Operator | ||
| predicate: key is not null (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: key (type: string), value (type: string) | ||
| outputColumnNames: _col0, _col1 | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Reduce Output Operator | ||
| key expressions: _col0 (type: string) | ||
| null sort order: z | ||
| sort order: + | ||
| Map-reduce partition columns: _col0 (type: string) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| value expressions: _col1 (type: string) | ||
| Execution mode: vectorized, llap | ||
| LLAP IO: all inputs | ||
| Reducer 4 | ||
| Execution mode: llap | ||
| Reduce Operator Tree: | ||
| Merge Join Operator | ||
| condition map: | ||
| Inner Join 0 to 1 | ||
| keys: | ||
| 0 _col0 (type: string) | ||
| 1 _col0 (type: string) | ||
| outputColumnNames: _col0, _col1, _col2, _col3 | ||
| Statistics: Num rows: 791 Data size: 281596 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Reduce Output Operator | ||
| key expressions: _col0 (type: string) | ||
| null sort order: z | ||
| sort order: + | ||
| Statistics: Num rows: 791 Data size: 281596 Basic stats: COMPLETE Column stats: COMPLETE | ||
| value expressions: _col1 (type: string), _col2 (type: string), _col3 (type: string) | ||
| Reducer 5 | ||
| Execution mode: vectorized, llap | ||
| Reduce Operator Tree: | ||
| Select Operator | ||
| expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string), VALUE._col1 (type: string), VALUE._col2 (type: string) | ||
| outputColumnNames: _col0, _col1, _col2, _col3 | ||
| Statistics: Num rows: 791 Data size: 281596 Basic stats: COMPLETE Column stats: COMPLETE | ||
| File Output Operator | ||
| compressed: false | ||
| Statistics: Num rows: 791 Data size: 281596 Basic stats: COMPLETE Column stats: COMPLETE | ||
| table: | ||
| input format: org.apache.hadoop.mapred.SequenceFileInputFormat | ||
| output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat | ||
| serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | ||
|
|
||
| Stage: Stage-0 | ||
| Move Operator | ||
| files: | ||
| hdfs directory: true | ||
| #### A masked pattern was here #### | ||
|
|
||
| Stage: Stage-4 | ||
| Tez | ||
| #### A masked pattern was here #### | ||
| Vertices: | ||
| Map 2 | ||
| Map Operator Tree: | ||
| TableScan | ||
| alias: src | ||
| filterExpr: (key <> '100') (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Filter Operator | ||
| predicate: (key <> '100') (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: key (type: string), value (type: string) | ||
| outputColumnNames: _col0, _col1 | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| File Output Operator | ||
| compressed: false | ||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| table: | ||
| input format: org.apache.hadoop.mapred.TextInputFormat | ||
| output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | ||
| serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe | ||
| name: default.another_materialized_cte | ||
| Execution mode: vectorized, llap | ||
| LLAP IO: all inputs | ||
|
|
||
| Stage: Stage-5 | ||
| Dependency Collection | ||
|
|
||
| Stage: Stage-3 | ||
| Move Operator | ||
| files: | ||
| hdfs directory: true | ||
| #### A masked pattern was here #### | ||
|
|
||
| Stage: Stage-6 | ||
| Fetch Operator | ||
| limit: -1 | ||
| Processor Tree: | ||
| ListSink | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.