Skip to content

Commit

Permalink
fix arrow2 python error
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaoying committed Aug 26, 2023
1 parent d544e32 commit 829bcba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
20 changes: 8 additions & 12 deletions connectorx-python/src/arrow2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@ fn to_ptrs(
let mut result = vec![];
let names = schema.fields.iter().map(|f| f.name.clone()).collect();

for rb in rbs {
for rb in rbs.into_iter() {
let mut cols = vec![];

for array in rb.columns() {
let array_ptr = Box::new(ffi::ArrowArray::empty());
let schema_ptr = Box::new(ffi::ArrowSchema::empty());
let array_ptr = Box::into_raw(array_ptr);
let schema_ptr = Box::into_raw(schema_ptr);
unsafe {
ffi::export_field_to_c(
&Field::new("", array.data_type().clone(), true),
);
ffi::export_array_to_c(array.clone());
};
for array in rb.into_arrays() {
let schema_ptr =
ffi::export_field_to_c(&Field::new("", array.data_type().clone(), true));
let array_ptr = ffi::export_array_to_c(array);
let array_ptr = Box::into_raw(Box::new(array_ptr));
let schema_ptr = Box::into_raw(Box::new(schema_ptr));

cols.push((array_ptr as uintptr_t, schema_ptr as uintptr_t));
}

Expand Down
1 change: 0 additions & 1 deletion connectorx/src/destinations/arrow2/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::typesystem::{ParameterizedFunc, ParameterizedOn};
use anyhow::anyhow;
use arrow2::array::{Array, MutableArray};
use arrow2::datatypes::Field;
use std::sync::Arc;

pub struct FNewBuilder;

Expand Down
4 changes: 2 additions & 2 deletions connectorx/src/destinations/arrow2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use errors::{Arrow2DestinationError, Result};
use fehler::throw;
use fehler::throws;
use funcs::{FFinishBuilder, FNewBuilder, FNewField};
use polars::prelude::{ArrowField, DataFrame, PolarsError, Series};
use polars::prelude::{DataFrame, PolarsError, Series};
use std::convert::TryFrom;
use std::sync::{Arc, Mutex};
pub use typesystem::Arrow2TypeSystem;
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Arrow2Destination {
.into_iter()
.zip(chunks.1)
.map(|(arr, field)| {
let a = Series::try_from((field.name.as_str(), arr)).map_err(|er| {
let a = Series::try_from((field.name.as_str(), arr)).map_err(|_| {
PolarsError::ComputeError("Couldn't build Series from box".into())
});
a
Expand Down

0 comments on commit 829bcba

Please sign in to comment.