From 14f51e88ec78fc077bb1c56f2e87f4bd1776ef5e Mon Sep 17 00:00:00 2001 From: Joe Isaacs Date: Thu, 2 Jan 2025 13:35:21 +0000 Subject: [PATCH] Convert into arrow without going via `into_canonical` (#1736) --- docs/guide.rst | 4 ++-- pyvortex/python/vortex/encoding.py | 4 ++-- pyvortex/src/expr.rs | 10 +++++----- pyvortex/src/io.rs | 6 +++--- vortex-array/src/arrow/record_batch.rs | 2 +- vortex-array/src/canonical.rs | 3 +-- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/docs/guide.rst b/docs/guide.rst index 454f01aa23..219a44b73b 100644 --- a/docs/guide.rst +++ b/docs/guide.rst @@ -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"]] @@ -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"]] diff --git a/pyvortex/python/vortex/encoding.py b/pyvortex/python/vortex/encoding.py index 1e765f1d72..41789cac9d 100644 --- a/pyvortex/python/vortex/encoding.py +++ b/pyvortex/python/vortex/encoding.py @@ -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"]] @@ -357,7 +357,7 @@ def array(obj: pyarrow.Array | list | Any) -> Array: [ -- is_valid: all not null - -- child 0 type: string_view + -- child 0 type: string [ "Braund", "Allen", diff --git a/pyvortex/src/expr.rs b/pyvortex/src/expr.rs index 2e1456d048..b3d8b87aa0 100644 --- a/pyvortex/src/expr.rs +++ b/pyvortex/src/expr.rs @@ -38,7 +38,7 @@ use crate::dtype::PyDType; /// [ /// 57 /// ] -/// -- child 1 type: string_view +/// -- child 1 type: string /// [ /// "Mikhail" /// ] @@ -56,7 +56,7 @@ use crate::dtype::PyDType; /// 25, /// 31 /// ] -/// -- child 1 type: string_view +/// -- child 1 type: string /// [ /// "Joseph", /// null @@ -73,7 +73,7 @@ use crate::dtype::PyDType; /// [ /// 25 /// ] -/// -- child 1 type: string_view +/// -- child 1 type: string /// [ /// "Joseph" /// ] @@ -90,7 +90,7 @@ use crate::dtype::PyDType; /// null, /// 57 /// ] -/// -- child 1 type: string_view +/// -- child 1 type: string /// [ /// "Angela", /// "Mikhail" @@ -110,7 +110,7 @@ use crate::dtype::PyDType; /// 25, /// null /// ] -/// -- child 1 type: string_view +/// -- child 1 type: string /// [ /// "Joseph", /// "Angela" diff --git a/pyvortex/src/io.rs b/pyvortex/src/io.rs index c81bb364dd..3fdb588522 100644 --- a/pyvortex/src/io.rs +++ b/pyvortex/src/io.rs @@ -48,7 +48,7 @@ use crate::{PyArray, TOKIO_RUNTIME}; /// 57, /// null /// ] -/// -- child 1 type: string_view +/// -- child 1 type: string /// [ /// "Joseph", /// null, @@ -78,7 +78,7 @@ use crate::{PyArray, TOKIO_RUNTIME}; /// >>> d.to_arrow_array() /// /// -- is_valid: all not null -/// -- child 0 type: string_view +/// -- child 0 type: string /// [ /// "Joseph", /// null, @@ -98,7 +98,7 @@ use crate::{PyArray, TOKIO_RUNTIME}; /// [ /// 57 /// ] -/// -- child 1 type: string_view +/// -- child 1 type: string /// [ /// "Mikhail" /// ] diff --git a/vortex-array/src/arrow/record_batch.rs b/vortex-array/src/arrow/record_batch.rs index 25332b127f..d66e70431f 100644 --- a/vortex-array/src/arrow/record_batch.rs +++ b/vortex-array/src/arrow/record_batch.rs @@ -49,7 +49,7 @@ impl TryFrom for RecordBatch { type Error = VortexError; fn try_from(value: StructArray) -> VortexResult { - 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)) } diff --git a/vortex-array/src/canonical.rs b/vortex-array/src/canonical.rs index 44529177bb..f08b41698f 100644 --- a/vortex-array/src/canonical.rs +++ b/vortex-array/src/canonical.rs @@ -201,9 +201,8 @@ fn struct_to_arrow(struct_array: StructArray) -> VortexResult { .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::>>()?;