Skip to content
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

Map creation fixes and refactoring #10436

Merged
merged 7 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
review fixes and missing test
  • Loading branch information
taniabogatsch committed Feb 7, 2024
commit 294f350827cba10b8eb5116c571e992a940e28ea
2 changes: 1 addition & 1 deletion src/core_functions/scalar/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void MapFunction(DataChunk &args, ExpressionState &, Vector &result) {
if (!keys_data.validity.RowIsValid(keys_idx)) {
MapVector::EvalMapInvalidReason(MapInvalidReason::NULL_KEY_LIST);
}
if (!keys_data.validity.RowIsValid(keys_idx)) {
if (!values_data.validity.RowIsValid(values_idx)) {
MapVector::EvalMapInvalidReason(MapInvalidReason::NULL_VALUE_LIST);
}
if (keys_entry.length != values_entry.length) {
Expand Down
26 changes: 23 additions & 3 deletions test/sql/types/nested/map/map_error.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ SELECT MAP(NULL)
----
Invalid map argument(s)

# same map keys in a MAP

statement ok
CREATE TABLE tbl (a INTEGER[], b TEXT[])

Expand Down Expand Up @@ -69,4 +67,26 @@ CREATE TABLE t AS SELECT MAP(list_value(1, 2, 3), list_value(10, 9, 10)) AS m;
statement error
SELECT struct_extract(m, 'key') FROM t;
----
No function matches the given name and argument types
No function matches the given name and argument types

statement ok
CREATE TABLE null_keys_list (k INT[], v INT[]);

statement ok
INSERT INTO null_keys_list VALUES ([1], [2]), (NULL, [4]);

statement error
SELECT MAP(k, v) FROM null_keys_list;
----
The list of map keys must not be NULL.

statement ok
CREATE TABLE null_values_list (k INT[], v INT[]);

statement ok
INSERT INTO null_values_list VALUES ([1], [2]), ([4], NULL);

statement error
SELECT MAP(k, v) FROM null_values_list;
----
The list of map values must not be NULL.
Loading