Skip to content
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

Convert into arrow without going via into_canonical #1736

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading