Fix null input in map_keys/values#14401
Merged
xudong963 merged 3 commits intoapache:mainfrom Feb 3, 2025
Merged
Conversation
cht42
commented
Feb 1, 2025
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod test { |
Contributor
Author
There was a problem hiding this comment.
cannot use slt tests as we can't cast null to Map
see https://github.com/apache/arrow-rs/blob/a6648fe53bc386eb8f491e68dca3d2bdee6c549c/arrow-schema/src/datatype_parse.rs#L683
Contributor
There was a problem hiding this comment.
I think you can test it using slt with this trick (create a column with non null value and then insert a NULL into it)
DataFusion CLI v44.0.0
> create table foo as values (MAP {'foo': 'bar'});
0 row(s) fetched.
Elapsed 0.037 seconds.
> insert into foo values (NULL);
+-------+
| count |
+-------+
| 1 |
+-------+
1 row(s) fetched.
Elapsed 0.016 seconds.
> select * from foo;
+------------+
| column1 |
+------------+
| {foo: bar} |
| NULL |
+------------+
2 row(s) fetched.
Elapsed 0.004 seconds.
> select column1, arrow_typeof(column1) from foo;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| column1 | arrow_typeof(foo.column1) |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {foo: bar} | Map(Field { name: "entries", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "value", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, false) |
| NULL | Map(Field { name: "entries", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "value", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, false) |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 row(s) fetched.
Elapsed 0.006 seconds.
alamb
reviewed
Feb 3, 2025
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod test { |
Contributor
There was a problem hiding this comment.
I think you can test it using slt with this trick (create a column with non null value and then insert a NULL into it)
DataFusion CLI v44.0.0
> create table foo as values (MAP {'foo': 'bar'});
0 row(s) fetched.
Elapsed 0.037 seconds.
> insert into foo values (NULL);
+-------+
| count |
+-------+
| 1 |
+-------+
1 row(s) fetched.
Elapsed 0.016 seconds.
> select * from foo;
+------------+
| column1 |
+------------+
| {foo: bar} |
| NULL |
+------------+
2 row(s) fetched.
Elapsed 0.004 seconds.
> select column1, arrow_typeof(column1) from foo;
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| column1 | arrow_typeof(foo.column1) |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {foo: bar} | Map(Field { name: "entries", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "value", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, false) |
| NULL | Map(Field { name: "entries", data_type: Struct([Field { name: "key", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "value", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }, false) |
+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 row(s) fetched.
Elapsed 0.006 seconds.
alamb
approved these changes
Feb 3, 2025
xudong963
approved these changes
Feb 3, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue does this PR close?
Closes #14400.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?