feat: introduce ArrowNative wrapper struct for adding data that is already a RecordBatchReader (#1139)

In
2de226220b
I added a new `IntoArrow` trait for adding data into a table.
Unfortunately, it seems my approach for implementing the trait for
"things that are already record batch readers" was flawed. This PR
corrects that flaw and, conveniently, removes the need to box readers at
all (though it is ok if you do).
This commit is contained in:
Weston Pace
2024-03-20 13:28:17 -07:00
parent f6e9f8e3f4
commit 968c62cb8f
7 changed files with 26 additions and 49 deletions

View File

@@ -95,7 +95,7 @@ impl Connection {
let mode = Self::parse_create_mode_str(mode)?;
let batches = Box::new(ArrowArrayStreamReader::from_pyarrow(data)?);
let batches = ArrowArrayStreamReader::from_pyarrow(data)?;
future_into_py(self_.py(), async move {
let table = inner
.create_table(name, batches)

View File

@@ -64,7 +64,7 @@ impl Table {
}
pub fn add<'a>(self_: PyRef<'a, Self>, data: &PyAny, mode: String) -> PyResult<&'a PyAny> {
let batches = Box::new(ArrowArrayStreamReader::from_pyarrow(data)?);
let batches = ArrowArrayStreamReader::from_pyarrow(data)?;
let mut op = self_.inner_ref()?.add(batches);
if mode == "append" {
op = op.mode(AddDataMode::Append);