Skip to content

Commit

Permalink
feat: experimental support for further nested types (#318)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Mause authored Jun 8, 2024
1 parent 2fea269 commit fe9a3ab
Show file tree
Hide file tree
Showing 7 changed files with 471 additions and 34 deletions.
1 change: 0 additions & 1 deletion crates/duckdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,6 @@ mod test {
}

mod query_and_then_tests {

use super::*;

#[derive(Debug)]
Expand Down
17 changes: 15 additions & 2 deletions crates/duckdb/src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{Error, Result, Statement};
use crate::types::{self, EnumType, FromSql, FromSqlError, ListType, ValueRef};

use arrow::{
array::{self, Array, ArrayRef, DictionaryArray, ListArray, StructArray},
array::{self, Array, ArrayRef, DictionaryArray, FixedSizeListArray, ListArray, MapArray, StructArray},
datatypes::*,
};
use fallible_iterator::FallibleIterator;
Expand Down Expand Up @@ -608,7 +608,20 @@ impl<'stmt> Row<'stmt> {
row,
)
}
_ => unreachable!("invalid value: {} {}", col, column.data_type()),
DataType::Struct(_) => {
let res = column.as_any().downcast_ref::<StructArray>().unwrap();
ValueRef::Struct(res, row)
}
DataType::Map(..) => {
let arr = column.as_any().downcast_ref::<MapArray>().unwrap();
ValueRef::Map(arr, row)
}
DataType::FixedSizeList(..) => {
let arr = column.as_any().downcast_ref::<FixedSizeListArray>().unwrap();
ValueRef::Array(arr, row)
}
DataType::Union(..) => ValueRef::Union(column, row),
_ => unreachable!("invalid value: {}, {}", col, column.data_type()),
}
}

Expand Down
Loading

0 comments on commit fe9a3ab

Please sign in to comment.