Skip to content

Commit

Permalink
Convert into arrow without going via into_canonical (#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-isaacs authored Jan 2, 2025
1 parent 1b992fe commit 14f51e8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ If you have a struct array, use :meth:`.Array.to_arrow_table` to construct an Ar
>>> struct_vtx.to_arrow_table()
pyarrow.Table
age: int64
name: string_view
name: string
----
age: [[25,31,33,57]]
name: [["Joseph","Narendra","Angela","Mikhail"]]
Expand All @@ -116,7 +116,7 @@ Pandas
>>> vortex.array(df).to_arrow_table()
pyarrow.Table
age: int64
name: string_view
name: string
----
age: [[25,31,33,57]]
name: [["Joseph","Narendra","Angela","Mikhail"]]
Expand Down
4 changes: 2 additions & 2 deletions pyvortex/python/vortex/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _Array_to_arrow_table(self: _encoding.Array) -> pyarrow.Table:
>>> array.to_arrow_table()
pyarrow.Table
age: int64
name: string_view
name: string
----
age: [[25,31,33,57]]
name: [["Joseph","Narendra","Angela","Mikhail"]]
Expand Down Expand Up @@ -357,7 +357,7 @@ def array(obj: pyarrow.Array | list | Any) -> Array:
<pyarrow.lib.ChunkedArray object at ...>
[
-- is_valid: all not null
-- child 0 type: string_view
-- child 0 type: string
[
"Braund",
"Allen",
Expand Down
10 changes: 5 additions & 5 deletions pyvortex/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::dtype::PyDType;
/// [
/// 57
/// ]
/// -- child 1 type: string_view
/// -- child 1 type: string
/// [
/// "Mikhail"
/// ]
Expand All @@ -56,7 +56,7 @@ use crate::dtype::PyDType;
/// 25,
/// 31
/// ]
/// -- child 1 type: string_view
/// -- child 1 type: string
/// [
/// "Joseph",
/// null
Expand All @@ -73,7 +73,7 @@ use crate::dtype::PyDType;
/// [
/// 25
/// ]
/// -- child 1 type: string_view
/// -- child 1 type: string
/// [
/// "Joseph"
/// ]
Expand All @@ -90,7 +90,7 @@ use crate::dtype::PyDType;
/// null,
/// 57
/// ]
/// -- child 1 type: string_view
/// -- child 1 type: string
/// [
/// "Angela",
/// "Mikhail"
Expand All @@ -110,7 +110,7 @@ use crate::dtype::PyDType;
/// 25,
/// null
/// ]
/// -- child 1 type: string_view
/// -- child 1 type: string
/// [
/// "Joseph",
/// "Angela"
Expand Down
6 changes: 3 additions & 3 deletions pyvortex/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use crate::{PyArray, TOKIO_RUNTIME};
/// 57,
/// null
/// ]
/// -- child 1 type: string_view
/// -- child 1 type: string
/// [
/// "Joseph",
/// null,
Expand Down Expand Up @@ -78,7 +78,7 @@ use crate::{PyArray, TOKIO_RUNTIME};
/// >>> d.to_arrow_array()
/// <pyarrow.lib.StructArray object at ...>
/// -- is_valid: all not null
/// -- child 0 type: string_view
/// -- child 0 type: string
/// [
/// "Joseph",
/// null,
Expand All @@ -98,7 +98,7 @@ use crate::{PyArray, TOKIO_RUNTIME};
/// [
/// 57
/// ]
/// -- child 1 type: string_view
/// -- child 1 type: string
/// [
/// "Mikhail"
/// ]
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/arrow/record_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl TryFrom<StructArray> for RecordBatch {
type Error = VortexError;

fn try_from(value: StructArray) -> VortexResult<Self> {
let array_ref = value.into_canonical()?.into_arrow()?;
let array_ref = value.into_array().into_arrow()?;
let struct_array = as_struct_array(array_ref.as_ref());
Ok(Self::from(struct_array))
}
Expand Down
3 changes: 1 addition & 2 deletions vortex-array/src/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,8 @@ fn struct_to_arrow(struct_array: StructArray) -> VortexResult<ArrayRef> {
.iter()
.zip(struct_array.children())
.map(|(name, f)| {
f.into_canonical()
f.into_arrow()
.map_err(|err| err.with_context(format!("Failed to canonicalize field {}", name)))
.and_then(|c| c.into_arrow())
})
.collect::<VortexResult<Vec<_>>>()?;

Expand Down

0 comments on commit 14f51e8

Please sign in to comment.