Skip to content

Commit

Permalink
set nulls correctly in the child list
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishj committed May 27, 2024
1 parent 8ab5a2f commit 870e830
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions expected/array_type_support.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ create extension quack;
CREATE TABLE int_array_1d(a INT[]);
INSERT INTO int_array_1d SELECT CAST(a as INT[]) FROM (VALUES
('{1, 2, 3}'),
('{4, 5, 6, 7}'),
('{4, 5, NULL, 7}'),
(NULL),
('{}')
) t(a);
SELECT * FROM int_array_1d;
a
-----------
a
--------------
{1,2,3}
{4,5,6,7}
{4,5,NULL,7}

{}
(4 rows)
Expand Down
2 changes: 1 addition & 1 deletion sql/array_type_support.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ create extension quack;
CREATE TABLE int_array_1d(a INT[]);
INSERT INTO int_array_1d SELECT CAST(a as INT[]) FROM (VALUES
('{1, 2, 3}'),
('{4, 5, 6, 7}'),
('{4, 5, NULL, 7}'),
(NULL),
('{}')
) t(a);
Expand Down
6 changes: 3 additions & 3 deletions src/quack_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ ConvertPostgresToDuckValue(Datum value, duckdb::Vector &result, idx_t offset) {
case duckdb::LogicalTypeId::LIST: {
auto &child = duckdb::ListVector::GetEntry(result);


// Convert Datum to ArrayType
auto array = DatumGetArrayTypeP(value);

Expand Down Expand Up @@ -565,12 +564,13 @@ ConvertPostgresToDuckValue(Datum value, duckdb::Vector &result, idx_t offset) {
switch (child_id) {
case duckdb::LogicalType::INTEGER: {
for (int i = 0; i < nelems; i++) {
idx_t dest_idx = child_offset + i;
if (nulls[i]) {
auto &array_mask = duckdb::FlatVector::Validity(child);
array_mask.SetInvalid(i);
array_mask.SetInvalid(dest_idx);
continue;
}
ConvertPostgresToDuckValue(elems[i], child, child_offset + i);
ConvertPostgresToDuckValue(elems[i], child, dest_idx);
}
break;
}
Expand Down

0 comments on commit 870e830

Please sign in to comment.