From 1a895db8ead92d6460ccf3b9bf829e1b1b55d558 Mon Sep 17 00:00:00 2001 From: peasee <98815791+peasee@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:27:14 +1000 Subject: [PATCH 1/2] fix: Support boolean lists --- crates/duckdb/src/vtab/arrow.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/duckdb/src/vtab/arrow.rs b/crates/duckdb/src/vtab/arrow.rs index 219f6f71..03da11cb 100644 --- a/crates/duckdb/src/vtab/arrow.rs +++ b/crates/duckdb/src/vtab/arrow.rs @@ -525,7 +525,7 @@ fn list_array_to_vector>( let value_array = array.values(); let mut child = out.child(value_array.len()); match value_array.data_type() { - dt if dt.is_primitive() => { + dt if dt.is_primitive() || matches!(dt, DataType::Boolean) => { primitive_array_to_vector(value_array.as_ref(), &mut child)?; } DataType::Utf8 => { @@ -556,7 +556,7 @@ fn fixed_size_list_array_to_vector( let value_array = array.values(); let mut child = out.child(value_array.len()); match value_array.data_type() { - dt if dt.is_primitive() => { + dt if dt.is_primitive() || matches!(dt, DataType::Boolean) => { primitive_array_to_vector(value_array.as_ref(), &mut child)?; } DataType::Utf8 => { From 37b5ab3cc1ab7d82cf89571721138664cd1fa9a3 Mon Sep 17 00:00:00 2001 From: peasee <98815791+peasee@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:43:13 +1000 Subject: [PATCH 2/2] test: Add boolean list roundtrip test --- crates/duckdb/src/vtab/arrow.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/duckdb/src/vtab/arrow.rs b/crates/duckdb/src/vtab/arrow.rs index 03da11cb..27b726fa 100644 --- a/crates/duckdb/src/vtab/arrow.rs +++ b/crates/duckdb/src/vtab/arrow.rs @@ -702,8 +702,8 @@ mod test { use crate::{Connection, Result}; use arrow::{ array::{ - Array, ArrayRef, AsArray, BinaryArray, Date32Array, Date64Array, Decimal128Array, Decimal256Array, - DurationSecondArray, FixedSizeListArray, GenericByteArray, GenericListArray, Int32Array, + Array, ArrayRef, AsArray, BinaryArray, BooleanArray, Date32Array, Date64Array, Decimal128Array, + Decimal256Array, DurationSecondArray, FixedSizeListArray, GenericByteArray, GenericListArray, Int32Array, IntervalDayTimeArray, IntervalMonthDayNanoArray, IntervalYearMonthArray, LargeStringArray, ListArray, OffsetSizeTrait, PrimitiveArray, StringArray, StructArray, Time32SecondArray, Time64MicrosecondArray, TimestampMicrosecondArray, TimestampMillisecondArray, TimestampNanosecondArray, TimestampSecondArray, @@ -977,6 +977,24 @@ mod test { Ok(()) } + #[test] + fn test_boolean_array_roundtrip() -> Result<(), Box> { + check_generic_array_roundtrip(ListArray::new( + Arc::new(Field::new("item", DataType::Boolean, true)), + OffsetBuffer::new(ScalarBuffer::from(vec![0, 2, 4, 5])), + Arc::new(BooleanArray::from(vec![ + Some(true), + Some(false), + Some(true), + Some(true), + Some(false), + ])), + None, + ))?; + + Ok(()) + } + //field: FieldRef, size: i32, values: ArrayRef, nulls: Option #[test] fn test_fixed_array_roundtrip() -> Result<(), Box> {