Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishj committed Apr 19, 2024
1 parent 58c44f6 commit d54e152
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/core_functions/scalar/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ static void MapFunctionEmptyInput(Vector &result, const idx_t row_count) {
result.Verify(row_count);
}

static bool MapIsNull(const LogicalType &map) {
D_ASSERT(map.id() == LogicalTypeId::MAP);
auto &key = MapType::KeyType(map);
auto &value = MapType::ValueType(map);
return (key.id() == LogicalTypeId::SQLNULL && value.id() == LogicalTypeId::SQLNULL);
static bool MapIsNull(DataChunk &chunk) {
if (chunk.data.empty()) {
return false;
}
D_ASSERT(chunk.data.size() == 2);
auto &keys = chunk.data[0];
auto &values = chunk.data[1];

if (keys.GetType().id() == LogicalTypeId::SQLNULL) {
return true;
}
if (values.GetType().id() == LogicalTypeId::SQLNULL) {
return true;
}
return false;
}

static void MapFunction(DataChunk &args, ExpressionState &, Vector &result) {
Expand All @@ -36,7 +46,7 @@ static void MapFunction(DataChunk &args, ExpressionState &, Vector &result) {
// - key names are unique
D_ASSERT(result.GetType().id() == LogicalTypeId::MAP);

if (MapIsNull(result.GetType())) {
if (MapIsNull(args)) {
auto &validity = FlatVector::Validity(result);
validity.SetInvalid(0);
result.SetVectorType(VectorType::CONSTANT_VECTOR);
Expand Down
3 changes: 3 additions & 0 deletions test/sql/types/nested/map/test_map_subscript.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# description: Test cardinality function for maps
# group: [map]

statement ok
pragma enable_verification

# Single element on map
query I
select m[1] from (select MAP(LIST_VALUE(1, 2, 3, 4),LIST_VALUE(10, 9, 8, 7)) as m) as T
Expand Down

0 comments on commit d54e152

Please sign in to comment.