-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add support for using ListView arrays and types through FFI #8822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d0980b1
ff3dc75
7375a94
c0e5df9
cedca3b
6c0e7a4
5b00813
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1783,7 +1783,7 @@ impl DataTypeLayout { | |
| }, | ||
| ], | ||
| can_contain_null_mask: true, | ||
| variadic: true, | ||
| variadic: false, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bug, see the spec, list views aren't represented by a variable number of buffers. |
||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -456,6 +456,14 @@ impl TryFrom<&FFI_ArrowSchema> for DataType { | |
| let c_child = c_schema.child(0); | ||
| DataType::LargeList(Arc::new(Field::try_from(c_child)?)) | ||
| } | ||
| "+vl" => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double checked that this matches https://arrow.apache.org/docs/format/CDataInterface.html#data-type-description-format-strings ✅ |
||
| let c_child = c_schema.child(0); | ||
| DataType::ListView(Arc::new(Field::try_from(c_child)?)) | ||
| } | ||
| "+vL" => { | ||
| let c_child = c_schema.child(0); | ||
| DataType::LargeListView(Arc::new(Field::try_from(c_child)?)) | ||
| } | ||
| "+s" => { | ||
| let fields = c_schema.children().map(Field::try_from); | ||
| DataType::Struct(fields.collect::<Result<_, ArrowError>>()?) | ||
|
|
@@ -657,6 +665,8 @@ impl TryFrom<&DataType> for FFI_ArrowSchema { | |
| let children = match dtype { | ||
| DataType::List(child) | ||
| | DataType::LargeList(child) | ||
| | DataType::ListView(child) | ||
| | DataType::LargeListView(child) | ||
| | DataType::FixedSizeList(child, _) | ||
| | DataType::Map(child, _) => { | ||
| vec![FFI_ArrowSchema::try_from(child.as_ref())?] | ||
|
|
@@ -746,6 +756,8 @@ fn get_format_string(dtype: &DataType) -> Result<Cow<'static, str>, ArrowError> | |
| DataType::Interval(IntervalUnit::MonthDayNano) => Ok("tin".into()), | ||
| DataType::List(_) => Ok("+l".into()), | ||
| DataType::LargeList(_) => Ok("+L".into()), | ||
| DataType::ListView(_) => Ok("+vl".into()), | ||
| DataType::LargeListView(_) => Ok("+vL".into()), | ||
| DataType::Struct(_) => Ok("+s".into()), | ||
| DataType::Map(_, _) => Ok("+m".into()), | ||
| DataType::RunEndEncoded(_, _) => Ok("+r".into()), | ||
|
|
@@ -874,6 +886,16 @@ mod tests { | |
| DataType::Int16, | ||
| false, | ||
| )))); | ||
| round_trip_type(DataType::ListView(Arc::new(Field::new( | ||
| "a", | ||
| DataType::Int16, | ||
| false, | ||
| )))); | ||
| round_trip_type(DataType::LargeListView(Arc::new(Field::new( | ||
| "a", | ||
| DataType::Int16, | ||
| false, | ||
| )))); | ||
| round_trip_type(DataType::Struct(Fields::from(vec![Field::new( | ||
| "a", | ||
| DataType::Utf8, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nicer when working with IDEs.