Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion/functions-nested/src/map_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ fn map_keys_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
Arc::new(Field::new_list_field(map_array.key_type().clone(), false)),
map_array.offsets().clone(),
Arc::clone(map_array.keys()),
None,
map_array.nulls().cloned(),
)))
}
2 changes: 1 addition & 1 deletion datafusion/functions-nested/src/map_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ fn map_values_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
Arc::new(Field::new_list_field(map_array.value_type().clone(), true)),
map_array.offsets().clone(),
Arc::clone(map_array.values()),
None,
map_array.nulls().cloned(),
)))
}
11 changes: 9 additions & 2 deletions datafusion/sqllogictest/test_files/map.slt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ AS VALUES
(MAP {7: [1, NULL, 3], 8: [9, NULL, 6], 9: [7, 8, 9]}, 4, 4.0, '4')
;

statement ok
INSERT INTO map_array_table_1 VALUES (NULL, 2, 1.0, '3');

statement ok
CREATE TABLE map_array_table_2
AS VALUES
Expand Down Expand Up @@ -198,7 +201,7 @@ query error DataFusion error: Execution error: map key cannot be null
SELECT MAP(['POST', 'HEAD', null], [41, 33, 30]);

statement error DataFusion error: Execution error: map key cannot be null
CREATE TABLE duplicated_keys_table
CREATE TABLE duplicated_keys_table
AS VALUES
(MAP {1: [1, NULL, 3], NULL: [4, NULL, 6]});

Expand All @@ -214,7 +217,7 @@ query error DataFusion error: Execution error: map key must be unique, duplicate
SELECT make_map('POST', 41, 'HEAD', 33, 'POST', 30);

statement error DataFusion error: Execution error: map key must be unique, duplicate key found: 1
CREATE TABLE duplicated_keys_table
CREATE TABLE duplicated_keys_table
AS VALUES
(MAP {1: [1, NULL, 3], 1: [4, NULL, 6]});

Expand Down Expand Up @@ -587,13 +590,15 @@ select map_extract(column1, 1), map_extract(column1, 5), map_extract(column1, 7)
[[1, NULL, 3]] [NULL] [NULL]
[NULL] [[4, NULL, 6]] [NULL]
[NULL] [NULL] [[1, NULL, 3]]
[NULL] [NULL] [NULL]

query ???
select map_extract(column1, column2), map_extract(column1, column3), map_extract(column1, column4) from map_array_table_1;
----
[[1, NULL, 3]] [[1, NULL, 3]] [[1, NULL, 3]]
[[4, NULL, 6]] [[4, NULL, 6]] [[4, NULL, 6]]
[NULL] [NULL] [NULL]
[NULL] [NULL] [NULL]

query ???
select map_extract(column1, column2), map_extract(column1, column3), map_extract(column1, column4) from map_array_table_2;
Expand Down Expand Up @@ -658,6 +663,7 @@ SELECT map_keys(column1) from map_array_table_1;
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
NULL


# Tests for map_values
Expand Down Expand Up @@ -709,6 +715,7 @@ SELECT map_values(column1) from map_array_table_1;
[[1, NULL, 3], [4, NULL, 6], [7, 8, 9]]
[[1, NULL, 3], [4, NULL, 6], [7, 8, 9]]
[[1, NULL, 3], [9, NULL, 6], [7, 8, 9]]
NULL

statement ok
drop table map_array_table_1;
Expand Down