-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29300: Wrong estimation for num rows in EXPLAIN with histogram statistics #6189
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
Merged
+258
−9
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --! qt:dataset:src | ||
| -- The histograms created by ANALYZE TABLE are not deterministic, so mask them: | ||
| --! qt:replace:/(Q[0-9]:) *[0-9.]+/$1 #Masked#/ | ||
| -- Same for the row estimations influenced by the histograms. | ||
| -- They are around 5 rows. If they are >= 20 something is really off: | ||
| --! qt:replace:/Statistics: Num rows: [0-1]?[0-9] Data size: [0-9]+/Statistics: Num rows: #Masked# Data size: #Masked#/ | ||
|
|
||
| set hive.fetch.task.conversion=none; | ||
| set metastore.stats.fetch.bitvector=true; | ||
| set metastore.stats.fetch.kll=true; | ||
| set hive.stats.fetch.column.stats=true; | ||
|
|
||
| CREATE TABLE sh2a AS (SELECT cast(key as int) as k1, cast(key as int) as k2 FROM src); | ||
|
|
||
| DESCRIBE FORMATTED sh2a k1; | ||
| DESCRIBE FORMATTED sh2a k2; | ||
|
|
||
| explain SELECT 1 FROM sh2a WHERE k1 < 10 AND k2 < 250; | ||
| SELECT count(1) FROM sh2a WHERE k1 < 10 AND k2 < 250; | ||
|
|
||
| set hive.stats.kll.enable=true; | ||
| CREATE TABLE sh2b AS (SELECT cast(key as int) as k1, cast(key as int) as k2 FROM src); | ||
| ANALYZE TABLE sh2b COMPUTE STATISTICS FOR COLUMNS; | ||
|
|
||
| DESCRIBE FORMATTED sh2b k1; | ||
| DESCRIBE FORMATTED sh2b k2; | ||
|
|
||
| explain SELECT 1 FROM sh2b WHERE k1 < 10 AND k2 < 250; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
215 changes: 215 additions & 0 deletions
215
ql/src/test/results/clientpositive/llap/stats_histogram2.q.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| PREHOOK: query: CREATE TABLE sh2a AS (SELECT cast(key as int) as k1, cast(key as int) as k2 FROM src) | ||
| PREHOOK: type: CREATETABLE_AS_SELECT | ||
| PREHOOK: Input: default@src | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@sh2a | ||
| POSTHOOK: query: CREATE TABLE sh2a AS (SELECT cast(key as int) as k1, cast(key as int) as k2 FROM src) | ||
| POSTHOOK: type: CREATETABLE_AS_SELECT | ||
| POSTHOOK: Input: default@src | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@sh2a | ||
| POSTHOOK: Lineage: sh2a.k1 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ] | ||
| POSTHOOK: Lineage: sh2a.k2 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ] | ||
| PREHOOK: query: DESCRIBE FORMATTED sh2a k1 | ||
| PREHOOK: type: DESCTABLE | ||
| PREHOOK: Input: default@sh2a | ||
| POSTHOOK: query: DESCRIBE FORMATTED sh2a k1 | ||
| POSTHOOK: type: DESCTABLE | ||
| POSTHOOK: Input: default@sh2a | ||
| col_name k1 | ||
| data_type int | ||
| min 0 | ||
| max 498 | ||
| num_nulls 0 | ||
| distinct_count 303 | ||
| avg_col_len | ||
| max_col_len | ||
| num_trues | ||
| num_falses | ||
| bit_vector HL | ||
| histogram | ||
| comment from deserializer | ||
| COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"k1\":\"true\",\"k2\":\"true\"}} | ||
| PREHOOK: query: DESCRIBE FORMATTED sh2a k2 | ||
| PREHOOK: type: DESCTABLE | ||
| PREHOOK: Input: default@sh2a | ||
| POSTHOOK: query: DESCRIBE FORMATTED sh2a k2 | ||
| POSTHOOK: type: DESCTABLE | ||
| POSTHOOK: Input: default@sh2a | ||
| col_name k2 | ||
| data_type int | ||
| min 0 | ||
| max 498 | ||
| num_nulls 0 | ||
| distinct_count 303 | ||
| avg_col_len | ||
| max_col_len | ||
| num_trues | ||
| num_falses | ||
| bit_vector HL | ||
| histogram | ||
| comment from deserializer | ||
| COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"k1\":\"true\",\"k2\":\"true\"}} | ||
| PREHOOK: query: explain SELECT 1 FROM sh2a WHERE k1 < 10 AND k2 < 250 | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@sh2a | ||
| #### A masked pattern was here #### | ||
| POSTHOOK: query: explain SELECT 1 FROM sh2a WHERE k1 < 10 AND k2 < 250 | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@sh2a | ||
| #### A masked pattern was here #### | ||
| STAGE DEPENDENCIES: | ||
| Stage-1 is a root stage | ||
| Stage-0 depends on stages: Stage-1 | ||
|
|
||
| STAGE PLANS: | ||
| Stage: Stage-1 | ||
| Tez | ||
| #### A masked pattern was here #### | ||
| Vertices: | ||
| Map 1 | ||
| Map Operator Tree: | ||
| TableScan | ||
| alias: sh2a | ||
| filterExpr: ((k1 < 10) and (k2 < 250)) (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Filter Operator | ||
| predicate: ((k1 < 10) and (k2 < 250)) (type: boolean) | ||
| Statistics: Num rows: #Masked# Data size: #Masked# Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: 1 (type: int) | ||
| outputColumnNames: _col0 | ||
| Statistics: Num rows: #Masked# Data size: #Masked# Basic stats: COMPLETE Column stats: COMPLETE | ||
| File Output Operator | ||
| compressed: false | ||
| Statistics: Num rows: #Masked# Data size: #Masked# 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 | ||
| Execution mode: vectorized, llap | ||
| LLAP IO: all inputs | ||
|
|
||
| Stage: Stage-0 | ||
| Fetch Operator | ||
| limit: -1 | ||
| Processor Tree: | ||
| ListSink | ||
|
|
||
| PREHOOK: query: SELECT count(1) FROM sh2a WHERE k1 < 10 AND k2 < 250 | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@sh2a | ||
| #### A masked pattern was here #### | ||
| POSTHOOK: query: SELECT count(1) FROM sh2a WHERE k1 < 10 AND k2 < 250 | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@sh2a | ||
| #### A masked pattern was here #### | ||
| 10 | ||
| PREHOOK: query: CREATE TABLE sh2b AS (SELECT cast(key as int) as k1, cast(key as int) as k2 FROM src) | ||
| PREHOOK: type: CREATETABLE_AS_SELECT | ||
| PREHOOK: Input: default@src | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@sh2b | ||
| POSTHOOK: query: CREATE TABLE sh2b AS (SELECT cast(key as int) as k1, cast(key as int) as k2 FROM src) | ||
| POSTHOOK: type: CREATETABLE_AS_SELECT | ||
| POSTHOOK: Input: default@src | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@sh2b | ||
| POSTHOOK: Lineage: sh2b.k1 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ] | ||
| POSTHOOK: Lineage: sh2b.k2 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ] | ||
| PREHOOK: query: ANALYZE TABLE sh2b COMPUTE STATISTICS FOR COLUMNS | ||
| PREHOOK: type: ANALYZE_TABLE | ||
| PREHOOK: Input: default@sh2b | ||
| PREHOOK: Output: default@sh2b | ||
| #### A masked pattern was here #### | ||
| POSTHOOK: query: ANALYZE TABLE sh2b COMPUTE STATISTICS FOR COLUMNS | ||
| POSTHOOK: type: ANALYZE_TABLE | ||
| POSTHOOK: Input: default@sh2b | ||
| POSTHOOK: Output: default@sh2b | ||
| #### A masked pattern was here #### | ||
| PREHOOK: query: DESCRIBE FORMATTED sh2b k1 | ||
| PREHOOK: type: DESCTABLE | ||
| PREHOOK: Input: default@sh2b | ||
| POSTHOOK: query: DESCRIBE FORMATTED sh2b k1 | ||
| POSTHOOK: type: DESCTABLE | ||
| POSTHOOK: Input: default@sh2b | ||
| col_name k1 | ||
| data_type int | ||
| min 0 | ||
| max 498 | ||
| num_nulls 0 | ||
| distinct_count 303 | ||
| avg_col_len | ||
| max_col_len | ||
| num_trues | ||
| num_falses | ||
| bit_vector HL | ||
| histogram Q1: #Masked#, Q2: #Masked#, Q3: #Masked# | ||
| comment from deserializer | ||
| COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"k1\":\"true\",\"k2\":\"true\"}} | ||
| PREHOOK: query: DESCRIBE FORMATTED sh2b k2 | ||
| PREHOOK: type: DESCTABLE | ||
| PREHOOK: Input: default@sh2b | ||
| POSTHOOK: query: DESCRIBE FORMATTED sh2b k2 | ||
| POSTHOOK: type: DESCTABLE | ||
| POSTHOOK: Input: default@sh2b | ||
| col_name k2 | ||
| data_type int | ||
| min 0 | ||
| max 498 | ||
| num_nulls 0 | ||
| distinct_count 303 | ||
| avg_col_len | ||
| max_col_len | ||
| num_trues | ||
| num_falses | ||
| bit_vector HL | ||
| histogram Q1: #Masked#, Q2: #Masked#, Q3: #Masked# | ||
| comment from deserializer | ||
| COLUMN_STATS_ACCURATE {\"BASIC_STATS\":\"true\",\"COLUMN_STATS\":{\"k1\":\"true\",\"k2\":\"true\"}} | ||
| PREHOOK: query: explain SELECT 1 FROM sh2b WHERE k1 < 10 AND k2 < 250 | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@sh2b | ||
| #### A masked pattern was here #### | ||
| POSTHOOK: query: explain SELECT 1 FROM sh2b WHERE k1 < 10 AND k2 < 250 | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@sh2b | ||
| #### A masked pattern was here #### | ||
| STAGE DEPENDENCIES: | ||
| Stage-1 is a root stage | ||
| Stage-0 depends on stages: Stage-1 | ||
|
|
||
| STAGE PLANS: | ||
| Stage: Stage-1 | ||
| Tez | ||
| #### A masked pattern was here #### | ||
| Vertices: | ||
| Map 1 | ||
| Map Operator Tree: | ||
| TableScan | ||
| alias: sh2b | ||
| filterExpr: ((k1 < 10) and (k2 < 250)) (type: boolean) | ||
| Statistics: Num rows: 500 Data size: 4000 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Filter Operator | ||
| predicate: ((k1 < 10) and (k2 < 250)) (type: boolean) | ||
| Statistics: Num rows: #Masked# Data size: #Masked# Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: 1 (type: int) | ||
| outputColumnNames: _col0 | ||
| Statistics: Num rows: #Masked# Data size: #Masked# Basic stats: COMPLETE Column stats: COMPLETE | ||
| File Output Operator | ||
| compressed: false | ||
| Statistics: Num rows: #Masked# Data size: #Masked# 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 | ||
| Execution mode: vectorized, llap | ||
| LLAP IO: all inputs | ||
|
|
||
| Stage: Stage-0 | ||
| Fetch Operator | ||
| limit: -1 | ||
| Processor Tree: | ||
| ListSink | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.