You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Async UDF returning a scalar fails with "all columns in a record batch must have the same length" #25875
If an async UDF returns ColumnarValue::Scalar (e.g. all arguments are literals), queries over more than one row fail with all columns in a record batch must have the same length. AsyncFuncExpr::invoke_with_args converts the scalar with to_array_of_size(1) instead of the number of rows.
To Reproduce
An async UDF that returns its argument, called with a literal on a table with more than one row:
#[derive(Debug,PartialEq,Eq,Hash)]structEchoUdf{signature:Signature,}implScalarUDFImplforEchoUdf{fnname(&self) -> &str{"echo"}fnsignature(&self) -> &Signature{&self.signature}fnreturn_type(&self, _:&[DataType]) -> Result<DataType>{Ok(DataType::Utf8)}fninvoke_with_args(&self, _:ScalarFunctionArgs) -> Result<ColumnarValue>{unreachable!()}}#[async_trait]implAsyncScalarUDFImplforEchoUdf{asyncfninvoke_async_with_args(&self,args:ScalarFunctionArgs) -> Result<ColumnarValue>{// A literal argument arrives as a scalar, so this returns a scalarOk(args.args[0].clone())}}let ctx = SessionContext::new();let udf = EchoUdf{signature:Signature::exact(vec![DataType::Utf8],Volatility::Volatile),};
ctx.register_udf(AsyncScalarUDF::new(Arc::new(udf)).into_scalar_udf());
ctx.sql("SELECT echo('constant') FROM (VALUES (1), (2), (3)) t(x)").await?
.show().await?;
Expected behavior
The scalar result applies to every row, so the query returns three rows of constant, the same as a non-async UDF returning a scalar.
Activity
hareshkh commentedon Sep 29, 2026
take
Expand scalar async UDF results to the batch row count (apache#25828)
Expand scalar async UDF results to the batch row count (apache#25828)