Skip to content

Commit bd22ef0

Browse files
Change AsyncScalarUDFImpl::invoke_async_with_args return type to ColumnarValue
1 parent d553ffd commit bd22ef0

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

datafusion-examples/examples/async_udf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl AsyncScalarUDFImpl for AskLLM {
199199
&self,
200200
args: ScalarFunctionArgs,
201201
_option: &ConfigOptions,
202-
) -> Result<ArrayRef> {
202+
) -> Result<ColumnarValue> {
203203
// in a real UDF you would likely want to special case constant
204204
// arguments to improve performance, but this example converts the
205205
// arguments to arrays for simplicity.
@@ -234,6 +234,6 @@ impl AsyncScalarUDFImpl for AskLLM {
234234
})
235235
.collect();
236236

237-
Ok(Arc::new(result_array))
237+
Ok(ColumnarValue::from(Arc::new(result_array) as ArrayRef))
238238
}
239239
}

datafusion/expr/src/async_udf.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717

1818
use crate::{ReturnFieldArgs, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl};
19-
use arrow::array::ArrayRef;
2019
use arrow::datatypes::{DataType, FieldRef};
2120
use async_trait::async_trait;
2221
use datafusion_common::config::ConfigOptions;
@@ -50,7 +49,7 @@ pub trait AsyncScalarUDFImpl: ScalarUDFImpl {
5049
&self,
5150
args: ScalarFunctionArgs,
5251
option: &ConfigOptions,
53-
) -> Result<ArrayRef>;
52+
) -> Result<ColumnarValue>;
5453
}
5554

5655
/// A scalar UDF that must be invoked using async methods
@@ -83,7 +82,7 @@ impl AsyncScalarUDF {
8382
&self,
8483
args: ScalarFunctionArgs,
8584
option: &ConfigOptions,
86-
) -> Result<ArrayRef> {
85+
) -> Result<ColumnarValue> {
8786
self.inner.invoke_async_with_args(args, option).await
8887
}
8988
}

datafusion/physical-expr/src/async_scalar_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl AsyncFuncExpr {
196196
);
197197
}
198198

199-
let datas = result_batches
199+
let datas = ColumnarValue::values_to_arrays(&result_batches)?
200200
.iter()
201201
.map(|b| b.to_data())
202202
.collect::<Vec<_>>();

0 commit comments

Comments
 (0)