Skip to content

Commit

Permalink
add support for DuckDB arrays when using Arrow's FixedSizeList
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeadie committed Jun 3, 2024
1 parent 7f09171 commit c5c104c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vtab/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ pub fn to_duckdb_logical_type(data_type: &DataType) -> Result<LogicalType, Box<d
Ok(LogicalType::list(&to_duckdb_logical_type(child.data_type())?))
} else if let DataType::LargeList(child) = data_type {

Check failure on line 197 in src/vtab/arrow.rs

View workflow job for this annotation

GitHub Actions / Test x86_64-unknown-linux-gnu

Diff in /home/runner/work/duckdb-rs/duckdb-rs/src/vtab/arrow.rs
Ok(LogicalType::list(&to_duckdb_logical_type(child.data_type())?))
} else if let DataType::FixedSizeList(child, _) = data_type {
Ok(LogicalType::list(&to_duckdb_logical_type(child.data_type())?))
} else if let DataType::FixedSizeList(child, array_size) = data_type {
Ok(LogicalType::array(&to_duckdb_logical_type(child.data_type())?, *array_size as u64))
} else {
Err(
format!("Unsupported data type: {data_type}, please file an issue https://github.com/wangfenjin/duckdb-rs")
Expand Down
9 changes: 9 additions & 0 deletions src/vtab/logical_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ impl LogicalType {
}
}

/// Creates an array type from its child type.
pub fn array(child_type: &LogicalType, array_size: u64) -> Self {
unsafe {
Self {
ptr: duckdb_create_array_type(child_type.ptr, array_size),
}
}
}

/// Creates a decimal type from its `width` and `scale`.
pub fn decimal(width: u8, scale: u8) -> Self {
unsafe {
Expand Down

0 comments on commit c5c104c

Please sign in to comment.