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

Handle 0-list maps (erroring out) and add test-case #10187

Merged
merged 2 commits into from Jan 11, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/core_functions/scalar/map/map.cpp
Expand Up @@ -32,12 +32,13 @@ static void AlignVectorToReference(const Vector &original, const Vector &referen

Vector expanded_const(ListType::GetChildType(original.GetType()), new_length);

auto expansion_factor = new_length / original_length;
if (expansion_factor != tuple_count) {
if (new_length != tuple_count * original_length) {
throw InvalidInputException("Error in MAP creation: key list and value list do not align. i.e. different "
"size or incompatible structure");
}
auto expansion_factor = original_length ? new_length / original_length : original_length;
CreateExpandedVector(original, expanded_const, expansion_factor);

result.Reference(expanded_const);
}

Expand Down
7 changes: 7 additions & 0 deletions test/sql/types/map/map_empty.test
@@ -0,0 +1,7 @@
# name: test/sql/types/map/map_empty.test
# description: Test empty map
# group: [map]

statement error
SELECT DISTINCT MAP { * : ? IN ( SELECT TRUE ) } ;
----