Skip to content

Apache DataFusion SQL Query Engine

ARROW-9971: [Rust] Improve speed of `take` by 2x-3x (change scaling with batch size)

Jorge C. Leitaob210cdb70b86
diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs
index 4e160a861d..7d24e90c67 100644
--- a/rust/datafusion/src/execution/context.rs
+++ b/rust/datafusion/src/execution/context.rs
@@ -515,7 +515,7 @@ mod tests {
use crate::physical_plan::functions::ScalarFunctionImplementation;
use crate::test;
use crate::variable::VarType;
- use arrow::array::{ArrayRef, Int32Array, StringArray};
+ use arrow::array::{ArrayRef, Int32Array, StringArray, StringArrayOps};
use arrow::compute::add;
use std::fs::File;
use std::{io::prelude::*, sync::Mutex};
diff --git a/rust/datafusion/src/physical_plan/common.rs b/rust/datafusion/src/physical_plan/common.rs
index 711c0d081e..3378c44a6c 100644
--- a/rust/datafusion/src/physical_plan/common.rs
+++ b/rust/datafusion/src/physical_plan/common.rs
@@ -24,7 +24,7 @@ use std::sync::{Arc, Mutex};
use crate::error::{ExecutionError, Result};
use crate::logical_plan::ScalarValue;
-use arrow::array::{self, ArrayRef};
+use arrow::array::{self, ArrayRef, StringArrayOps};
use arrow::datatypes::{DataType, SchemaRef};
use arrow::error::Result as ArrowResult;
use arrow::record_batch::{RecordBatch, RecordBatchReader};
diff --git a/rust/datafusion/src/physical_plan/datetime_expressions.rs b/rust/datafusion/src/physical_plan/datetime_expressions.rs
index 86a02db3cf..b043c18e09 100644
--- a/rust/datafusion/src/physical_plan/datetime_expressions.rs
+++ b/rust/datafusion/src/physical_plan/datetime_expressions.rs
@@ -21,7 +21,9 @@ use std::sync::Arc;
use crate::error::{ExecutionError, Result};
use arrow::{
- array::{Array, ArrayData, ArrayRef, StringArray, TimestampNanosecondArray},
+ array::{
+ Array, ArrayData, ArrayRef, StringArray, StringArrayOps, TimestampNanosecondArray,
+ },
buffer::Buffer,
datatypes::{DataType, TimeUnit, ToByteSlice},
};
diff --git a/rust/datafusion/src/physical_plan/expressions.rs b/rust/datafusion/src/physical_plan/expressions.rs
index 80cf9ea27c..5bb1ff110d 100644
--- a/rust/datafusion/src/physical_plan/expressions.rs
+++ b/rust/datafusion/src/physical_plan/expressions.rs
@@ -1509,7 +1509,8 @@ mod tests {
use crate::error::Result;
use crate::physical_plan::common::get_scalar_value;
use arrow::array::{
- LargeStringArray, PrimitiveArray, StringArray, Time64NanosecondArray,
+ LargeStringArray, PrimitiveArray, StringArray, StringArrayOps,
+ Time64NanosecondArray,
};
use arrow::datatypes::*;
diff --git a/rust/datafusion/src/physical_plan/functions.rs b/rust/datafusion/src/physical_plan/functions.rs
index ea6147cace..51208661d1 100644
--- a/rust/datafusion/src/physical_plan/functions.rs
+++ b/rust/datafusion/src/physical_plan/functions.rs
@@ -341,7 +341,7 @@ mod tests {
error::Result, logical_plan::ScalarValue, physical_plan::expressions::lit,
};
use arrow::{
- array::{ArrayRef, Float64Array, Int32Array, StringArray},
+ array::{ArrayRef, Float64Array, Int32Array, StringArray, StringArrayOps},
datatypes::Field,
record_batch::RecordBatch,
};
diff --git a/rust/datafusion/src/physical_plan/hash_aggregate.rs b/rust/datafusion/src/physical_plan/hash_aggregate.rs
index 4007bdfc0b..e8a72f5686 100644
--- a/rust/datafusion/src/physical_plan/hash_aggregate.rs
+++ b/rust/datafusion/src/physical_plan/hash_aggregate.rs
@@ -28,8 +28,8 @@ use crate::physical_plan::{
use arrow::array::{
ArrayBuilder, ArrayRef, Float32Array, Float64Array, Int16Array, Int32Array,
- Int64Array, Int8Array, StringArray, UInt16Array, UInt32Array, UInt64Array,
- UInt8Array,
+ Int64Array, Int8Array, StringArray, StringArrayOps, UInt16Array, UInt32Array,
+ UInt64Array, UInt8Array,
};
use arrow::array::{
Float32Builder, Float64Builder, Int16Builder, Int32Builder, Int64Builder,
diff --git a/rust/datafusion/src/physical_plan/string_expressions.rs b/rust/datafusion/src/physical_plan/string_expressions.rs
index 89e06f03bc..1216ac2a3d 100644
--- a/rust/datafusion/src/physical_plan/string_expressions.rs
+++ b/rust/datafusion/src/physical_plan/string_expressions.rs
@@ -18,7 +18,7 @@
//! String expressions
use crate::error::{ExecutionError, Result};
-use arrow::array::{Array, ArrayRef, StringArray, StringBuilder};
+use arrow::array::{Array, ArrayRef, StringArray, StringArrayOps, StringBuilder};
macro_rules! downcast_vec {
($ARGS:expr, $ARRAY_TYPE:ident) => {{
diff --git a/rust/datafusion/tests/user_defined_plan.rs b/rust/datafusion/tests/user_defined_plan.rs
index 98d2e01c6f..a6b691940a 100644
--- a/rust/datafusion/tests/user_defined_plan.rs
+++ b/rust/datafusion/tests/user_defined_plan.rs
@@ -59,7 +59,7 @@
//!
use arrow::{
- array::{Int64Array, StringArray},
+ array::{Int64Array, StringArray, StringArrayOps},
datatypes::SchemaRef,
error::ArrowError,
record_batch::{RecordBatch, RecordBatchReader},