Skip to content

Commit aca6251

Browse files
break: remove try_from struct array to record batch (#7488)
We cannot deprecate this TryFrom so it has to be removed Use: ArrowArrayExecutor::execute_record_batch --------- Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent ba08515 commit aca6251

File tree

4 files changed

+6
-61
lines changed

4 files changed

+6
-61
lines changed
Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
use std::sync::Arc;
5-
6-
use ::vortex::array::arrays::ChunkedArray;
7-
use ::vortex::array::arrays::chunked::ChunkedArrayExt;
8-
use ::vortex::array::arrays::listview::recursive_list_from_list_view;
9-
use arrow_array::RecordBatch;
10-
use arrow_schema::Schema;
114
#[cfg(feature = "lance")]
125
pub use lance_bench::compress::LanceCompressor;
136
pub mod parquet;
147
pub mod vortex;
15-
16-
pub fn chunked_to_vec_record_batch(
17-
chunked: ChunkedArray,
18-
) -> anyhow::Result<(Vec<RecordBatch>, Arc<Schema>)> {
19-
assert!(chunked.nchunks() > 0, "empty chunks");
20-
21-
let batches = chunked
22-
.iter_chunks()
23-
.map(|array| {
24-
// TODO(connor)[ListView]: The rust Parquet implementation does not support writing
25-
// `ListView` to Parquet files yet.
26-
let converted_array = recursive_list_from_list_view(array.clone())?;
27-
Ok(RecordBatch::try_from(&converted_array)?)
28-
})
29-
.collect::<anyhow::Result<Vec<_>>>()?;
30-
31-
let schema = batches[0].schema();
32-
Ok((batches, schema))
33-
}

vortex-array/public-api.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22120,12 +22120,6 @@ impl core::convert::From<vortex_array::arrays::datetime::TemporalData> for vorte
2212022120

2212122121
pub fn vortex_array::ArrayRef::from(value: vortex_array::arrays::datetime::TemporalData) -> Self
2212222122

22123-
impl core::convert::TryFrom<&vortex_array::ArrayRef> for arrow_array::record_batch::RecordBatch
22124-
22125-
pub type arrow_array::record_batch::RecordBatch::Error = vortex_error::VortexError
22126-
22127-
pub fn arrow_array::record_batch::RecordBatch::try_from(value: &vortex_array::ArrayRef) -> vortex_error::VortexResult<Self>
22128-
2212922123
impl core::convert::TryFrom<vortex_array::ArrayRef> for vortex_array::arrays::datetime::TemporalData
2213022124

2213122125
pub type vortex_array::arrays::datetime::TemporalData::Error = vortex_error::VortexError

vortex-array/src/arrow/record_batch.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,14 @@ use arrow_array::RecordBatch;
55
use arrow_array::cast::AsArray;
66
use arrow_schema::DataType;
77
use arrow_schema::Schema;
8-
use vortex_error::VortexError;
98
use vortex_error::VortexResult;
10-
use vortex_error::vortex_bail;
11-
use vortex_error::vortex_ensure;
129

13-
use crate::ArrayRef;
14-
use crate::Canonical;
1510
use crate::LEGACY_SESSION;
1611
use crate::VortexSessionExecute;
1712
use crate::array::IntoArray;
1813
use crate::arrays::StructArray;
1914
use crate::arrow::ArrowArrayExecutor;
2015

21-
// deprecated(note = "Use ArrowArrayExecutor::execute_record_batch instead")
22-
impl TryFrom<&ArrayRef> for RecordBatch {
23-
type Error = VortexError;
24-
25-
fn try_from(value: &ArrayRef) -> VortexResult<Self> {
26-
let Canonical::Struct(struct_array) = value.to_canonical()? else {
27-
vortex_bail!("RecordBatch can only be constructed from ")
28-
};
29-
30-
vortex_ensure!(
31-
struct_array.validity()?.no_nulls(),
32-
"RecordBatch can only be constructed from StructArray with no nulls"
33-
);
34-
35-
let data_type = struct_array.dtype().to_arrow_dtype()?;
36-
let array_ref = struct_array
37-
.into_array()
38-
.execute_arrow(Some(&data_type), &mut LEGACY_SESSION.create_execution_ctx())?;
39-
Ok(RecordBatch::from(array_ref.as_struct()))
40-
}
41-
}
42-
4316
impl StructArray {
4417
pub fn into_record_batch_with_schema(
4518
self,

vortex-bench/src/datasets/struct_list_of_ints.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ use std::fs::File;
55
use std::path::PathBuf;
66

77
use anyhow::Result;
8-
use arrow_array::RecordBatch;
98
use async_trait::async_trait;
109
use parquet::arrow::ArrowWriter;
1110
use rand::RngExt;
1211
use rand::SeedableRng;
1312
use rand::rngs::StdRng;
1413
use vortex::array::ArrayRef;
1514
use vortex::array::IntoArray;
15+
use vortex::array::LEGACY_SESSION;
16+
use vortex::array::VortexSessionExecute;
1617
use vortex::array::arrays::ChunkedArray;
1718
use vortex::array::arrays::ListArray;
1819
use vortex::array::arrays::PrimitiveArray;
1920
use vortex::array::arrays::StructArray;
2021
use vortex::array::arrays::chunked::ChunkedArrayExt;
2122
use vortex::array::arrays::listview::recursive_list_from_list_view;
23+
use vortex::array::arrow::ArrowArrayExecutor;
2224
use vortex::array::validity::Validity;
2325
use vortex::dtype::FieldNames;
2426

@@ -123,7 +125,9 @@ impl Dataset for StructListOfInts {
123125

124126
for chunk in chunked.iter_chunks() {
125127
let converted = recursive_list_from_list_view(chunk.clone())?;
126-
let batch = RecordBatch::try_from(&converted)?;
128+
let schema = converted.dtype().to_arrow_schema()?;
129+
let batch = converted
130+
.execute_record_batch(&schema, &mut LEGACY_SESSION.create_execution_ctx())?;
127131

128132
if writer.is_none() {
129133
writer = Some(ArrowWriter::try_new(

0 commit comments

Comments
 (0)