-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29637: Incorrect Results for NULL Predicate on Partition Column #6515
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
Open
deniskuzZ
wants to merge
3
commits into
apache:master
Choose a base branch
from
deniskuzZ:HIVE-29637
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+428
−27
Open
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
18 changes: 18 additions & 0 deletions
18
iceberg/iceberg-handler/src/test/queries/positive/iceberg_pcr_null_partition.q
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,18 @@ | ||
| set hive.exec.dynamic.partition.mode=nonstrict; | ||
| set hive.fetch.task.conversion=none; | ||
| set hive.explain.user=false; | ||
|
|
||
| drop table if exists ice_01; | ||
| create external table ice_01 (key string, value string) partitioned by (ds string) stored by iceberg; | ||
|
|
||
| insert into ice_01 partition (ds) select 'A', 'V1', '2000-04-08'; | ||
| insert into ice_01 partition (ds) select 'B', 'V2', 'null'; | ||
| insert into ice_01 partition (ds) select 'C', 'V3', null; | ||
|
|
||
| explain select key, value, ds from ice_01 where ds is null; | ||
| select key, value, ds from ice_01 where ds is null; | ||
|
|
||
| explain select key, value, ds from ice_01 where ds is not null; | ||
| select key, value, ds from ice_01 where ds is not null order by key; | ||
|
|
||
| select key, value, ds from ice_01 where ds = 'null'; |
150 changes: 150 additions & 0 deletions
150
iceberg/iceberg-handler/src/test/results/positive/iceberg_pcr_null_partition.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,150 @@ | ||
| PREHOOK: query: drop table if exists ice_01 | ||
| PREHOOK: type: DROPTABLE | ||
| PREHOOK: Output: database:default | ||
| POSTHOOK: query: drop table if exists ice_01 | ||
| POSTHOOK: type: DROPTABLE | ||
| POSTHOOK: Output: database:default | ||
| PREHOOK: query: create external table ice_01 (key string, value string) partitioned by (ds string) stored by iceberg | ||
| PREHOOK: type: CREATETABLE | ||
| PREHOOK: Output: database:default | ||
| PREHOOK: Output: default@ice_01 | ||
| POSTHOOK: query: create external table ice_01 (key string, value string) partitioned by (ds string) stored by iceberg | ||
| POSTHOOK: type: CREATETABLE | ||
| POSTHOOK: Output: database:default | ||
| POSTHOOK: Output: default@ice_01 | ||
| PREHOOK: query: insert into ice_01 partition (ds) select 'A', 'V1', '2000-04-08' | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_01 | ||
| POSTHOOK: query: insert into ice_01 partition (ds) select 'A', 'V1', '2000-04-08' | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_01 | ||
| PREHOOK: query: insert into ice_01 partition (ds) select 'B', 'V2', 'null' | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_01 | ||
| POSTHOOK: query: insert into ice_01 partition (ds) select 'B', 'V2', 'null' | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_01 | ||
| PREHOOK: query: insert into ice_01 partition (ds) select 'C', 'V3', null | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: _dummy_database@_dummy_table | ||
| PREHOOK: Output: default@ice_01 | ||
| POSTHOOK: query: insert into ice_01 partition (ds) select 'C', 'V3', null | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: _dummy_database@_dummy_table | ||
| POSTHOOK: Output: default@ice_01 | ||
| PREHOOK: query: explain select key, value, ds from ice_01 where ds is null | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@ice_01 | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: explain select key, value, ds from ice_01 where ds is null | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@ice_01 | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| 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: ice_01 | ||
| filterExpr: ds is null (type: boolean) | ||
| Statistics: Num rows: 1 Data size: 171 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: key (type: string), value (type: string), null (type: string) | ||
| outputColumnNames: _col0, _col1, _col2 | ||
| Statistics: Num rows: 1 Data size: 255 Basic stats: COMPLETE Column stats: COMPLETE | ||
| File Output Operator | ||
| compressed: false | ||
| Statistics: Num rows: 1 Data size: 255 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 | ||
|
|
||
| Stage: Stage-0 | ||
| Fetch Operator | ||
| limit: -1 | ||
| Processor Tree: | ||
| ListSink | ||
|
|
||
| PREHOOK: query: select key, value, ds from ice_01 where ds is null | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@ice_01 | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: select key, value, ds from ice_01 where ds is null | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@ice_01 | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| C V3 NULL | ||
| PREHOOK: query: explain select key, value, ds from ice_01 where ds is not null | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@ice_01 | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: explain select key, value, ds from ice_01 where ds is not null | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@ice_01 | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| 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: ice_01 | ||
| filterExpr: ds is not null (type: boolean) | ||
| Statistics: Num rows: 2 Data size: 530 Basic stats: COMPLETE Column stats: COMPLETE | ||
| Select Operator | ||
| expressions: key (type: string), value (type: string), ds (type: string) | ||
| outputColumnNames: _col0, _col1, _col2 | ||
| Statistics: Num rows: 2 Data size: 530 Basic stats: COMPLETE Column stats: COMPLETE | ||
| File Output Operator | ||
| compressed: false | ||
| Statistics: Num rows: 2 Data size: 530 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 | ||
|
|
||
| Stage: Stage-0 | ||
| Fetch Operator | ||
| limit: -1 | ||
| Processor Tree: | ||
| ListSink | ||
|
|
||
| PREHOOK: query: select key, value, ds from ice_01 where ds is not null order by key | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@ice_01 | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: select key, value, ds from ice_01 where ds is not null order by key | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@ice_01 | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| A V1 2000-04-08 | ||
| B V2 null | ||
| PREHOOK: query: select key, value, ds from ice_01 where ds = 'null' | ||
| PREHOOK: type: QUERY | ||
| PREHOOK: Input: default@ice_01 | ||
| PREHOOK: Output: hdfs://### HDFS PATH ### | ||
| POSTHOOK: query: select key, value, ds from ice_01 where ds = 'null' | ||
| POSTHOOK: type: QUERY | ||
| POSTHOOK: Input: default@ice_01 | ||
| POSTHOOK: Output: hdfs://### HDFS PATH ### | ||
| B V2 null |
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
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,17 @@ | ||
| set hive.exec.dynamic.partition.mode=nonstrict; | ||
| set hive.fetch.task.conversion=none; | ||
|
|
||
| drop table if exists pcr_t1; | ||
| create table pcr_t1 (key string, value string) partitioned by (ds string); | ||
|
|
||
| insert into pcr_t1 partition (ds) select 'A', 'V1', '2000-04-08'; | ||
| insert into pcr_t1 partition (ds) select 'B', 'V2', 'null'; | ||
| insert into pcr_t1 partition (ds) select 'C', 'V3', null; | ||
|
|
||
| explain select key, value, ds from pcr_t1 where ds is null; | ||
| select key, value, ds from pcr_t1 where ds is null; | ||
|
|
||
| explain select key, value, ds from pcr_t1 where ds is not null; | ||
| select key, value, ds from pcr_t1 where ds is not null order by key; | ||
|
|
||
| select key, value, ds from pcr_t1 where ds = 'null'; |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
There are more calls to
Warehouse#makeSpecFromNamemethods inIcebergTableUtil#convertNameToMetastorePartition,IcebergQueryCompactor, and potentially other places as well. Do we need to update them as well?Uh oh!
There was an error while loading. Please reload this page.
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.
The other call sites (e.g. IcebergTableUtil#convertNameToMetastorePartition) don't have access to
partitionData— they only receive the partition path string. Without the underlying partition data, there's no way to disambiguate whether"null"in the path originated from a trueNULLvalue or from a literal string"null". The fix here works precisely because we havepartitionDataavailable to check the actual value. If those other paths turn out to be affected, they'd need a different approach to obtain that context.Note: IcebergQueryCompactor should be fine — it deals with compaction where
NULLfiltering semantics aren't in play