Skip to content

Commit fe9a3ab

Browse files
authored
feat: experimental support for further nested types (#318)
* kinda working * add more docs * iterate on struct support * start on map support * amend type enum * add initial array support * add conversion between DataType and Type * add full test_all_types() test * add basic union read support * use better data structures * chore: fix up imports * Update test_all_types.rs * clippy
1 parent 2fea269 commit fe9a3ab

File tree

7 files changed

+471
-34
lines changed

7 files changed

+471
-34
lines changed

crates/duckdb/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,6 @@ mod test {
10031003
}
10041004

10051005
mod query_and_then_tests {
1006-
10071006
use super::*;
10081007

10091008
#[derive(Debug)]

crates/duckdb/src/row.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::{Error, Result, Statement};
44
use crate::types::{self, EnumType, FromSql, FromSqlError, ListType, ValueRef};
55

66
use arrow::{
7-
array::{self, Array, ArrayRef, DictionaryArray, ListArray, StructArray},
7+
array::{self, Array, ArrayRef, DictionaryArray, FixedSizeListArray, ListArray, MapArray, StructArray},
88
datatypes::*,
99
};
1010
use fallible_iterator::FallibleIterator;
@@ -608,7 +608,20 @@ impl<'stmt> Row<'stmt> {
608608
row,
609609
)
610610
}
611-
_ => unreachable!("invalid value: {} {}", col, column.data_type()),
611+
DataType::Struct(_) => {
612+
let res = column.as_any().downcast_ref::<StructArray>().unwrap();
613+
ValueRef::Struct(res, row)
614+
}
615+
DataType::Map(..) => {
616+
let arr = column.as_any().downcast_ref::<MapArray>().unwrap();
617+
ValueRef::Map(arr, row)
618+
}
619+
DataType::FixedSizeList(..) => {
620+
let arr = column.as_any().downcast_ref::<FixedSizeListArray>().unwrap();
621+
ValueRef::Array(arr, row)
622+
}
623+
DataType::Union(..) => ValueRef::Union(column, row),
624+
_ => unreachable!("invalid value: {}, {}", col, column.data_type()),
612625
}
613626
}
614627

0 commit comments

Comments
 (0)