Skip to content

Commit

Permalink
Handle 0-list maps (erroring out) and add test-case
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Jan 10, 2024
1 parent db09b50 commit 631158c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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 ) } ;
----

0 comments on commit 631158c

Please sign in to comment.