-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29473: prevent combining stats between SELECT and LV fields #6331
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
base: master
Are you sure you want to change the base?
Changes from all commits
533bce5
9f854a3
7f48c9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| create table lvj_stats (id string, f1 string); | ||
|
|
||
| insert into lvj_stats values | ||
| ('a','v1'), ('a','v2'), ('a','v3'), | ||
| ('b','v4'), ('b','v5'), ('b','v6'); | ||
|
|
||
| analyze table lvj_stats compute statistics; | ||
| analyze table lvj_stats compute statistics for columns; | ||
|
|
||
| -- Test that LV columns' stats no longer inflate SELECT columns' sizes | ||
| explain | ||
| select id, f1, count(*) | ||
| from (select id, f1 from lvj_stats group by id, f1) sub | ||
| lateral view posexplode(array(f1, f1)) t1 as pos1, val1 | ||
| group by id, f1; | ||
|
|
||
| select id, f1, count(*) | ||
| from (select id, f1 from lvj_stats group by id, f1) sub | ||
| lateral view posexplode(array(f1, f1)) t1 as pos1, val1 | ||
| group by id, f1; | ||
|
|
||
| -- Test that LV columns' stats no longer override NDV of a base column | ||
| alter table lvj_stats update statistics for column id set('numDVs'='0','numNulls'='0'); | ||
|
|
||
| explain | ||
| select id, count(*) | ||
| from (select id, f1 from lvj_stats group by id, f1) sub | ||
| lateral view posexplode(array(f1, f1)) t1 as pos1, val1 | ||
| group by id; | ||
|
|
||
| select id, count(*) | ||
| from (select id, f1 from lvj_stats group by id, f1) sub | ||
| lateral view posexplode(array(f1, f1)) t1 as pos1, val1 | ||
| group by id; | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -129,20 +129,20 @@ STAGE PLANS: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Select Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expressions: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputColumnNames: _col0, _col1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 500 Data size: 115500 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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. This is a typical example of LV column stats impacting the data size estimations of SELECT columns: ` Column Naming
The UDTF branch's column generator restarts at 0, so its internal stats use _col0 for the array expression — colliding with SELECT's _col0. Processing Comparison
Final Column Statistics
Data Size — LVJ Debug Output (500 rows)
Data Size — EXPLAIN Output (500 rows)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Group By Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aggregations: count() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keys: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minReductionHashAggr: 0.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode: hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputColumnNames: _col0, _col1, _col2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Reduce Output Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key expressions: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| null sort order: zz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sort order: ++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map-reduce partition columns: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value expressions: _col2 (type: bigint) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Select Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expressions: array(1,2,3) (type: array<int>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -157,20 +157,20 @@ STAGE PLANS: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Select Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expressions: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputColumnNames: _col0, _col1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 500 Data size: 115500 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 500 Data size: 89000 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Group By Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aggregations: count() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keys: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minReductionHashAggr: 0.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode: hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputColumnNames: _col0, _col1, _col2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Reduce Output Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key expressions: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| null sort order: zz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sort order: ++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map-reduce partition columns: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value expressions: _col2 (type: bigint) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Execution mode: llap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LLAP IO: all inputs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -191,13 +191,13 @@ STAGE PLANS: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minReductionHashAggr: 0.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode: hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputColumnNames: _col0, _col1, _col2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Reduce Output Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key expressions: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| null sort order: zz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sort order: ++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Map-reduce partition columns: _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value expressions: _col2 (type: bigint) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Reducer 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Execution mode: vectorized, llap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -207,14 +207,14 @@ STAGE PLANS: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keys: KEY._col0 (type: string), KEY._col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode: mergepartial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputColumnNames: _col0, _col1, _col2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Select Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expressions: _col2 (type: bigint), _col0 (type: string), _col1 (type: string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputColumnNames: _col0, _col1, _col2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File Output Operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compressed: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 154155 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Statistics: Num rows: 645 Data size: 119970 Basic stats: COMPLETE Column stats: COMPLETE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| table: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input format: org.apache.hadoop.mapred.SequenceFileInputFormat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add
set hive.stats.udtf.factor=2.0to ensure the scaling is working as expected?