You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/05/13 14:24:59 UTC

(datafusion) branch gh-readonly-queue/main/pr-22097-0c4ace8b77461cac3538d38b1122a7dbf08c4d4f created (now 8441a8f5e9)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-22097-0c4ace8b77461cac3538d38b1122a7dbf08c4d4f
in repository https://gitbox.apache.org/repos/asf/datafusion.git


      at 8441a8f5e9 Minor: Disallow async function in lambdas (#22097)

This branch includes the following new commits:

     new 8441a8f5e9 Minor: Disallow async function in lambdas (#22097)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


(datafusion) 01/01: Minor: Disallow async function in lambdas (#22097)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-22097-0c4ace8b77461cac3538d38b1122a7dbf08c4d4f
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 8441a8f5e9274f2f681f5e86906cbd35deb5639e
Author: gstvg <28...@users.noreply.github.com>
AuthorDate: Wed May 13 11:24:37 2026 -0300

    Minor: Disallow async function in lambdas (#22097)
    
    ## Which issue does this PR close?
    
    Part of #22091.
    
    ## Rationale for this change
    
    Current async udfs in lambdas fail with generic errors
    
    ## What changes are included in this PR?
    
    Report an explicit error when trying to create a lambda with async
    functions
    
    ## Are these changes tested?
    
    One sqllogictest added to assert the friendly error
    
    ## Are there any user-facing changes?
    
    What failed before still fail but with a better error
    
    ---------
    
    Co-authored-by: debonageo <84...@users.noreply.github.com>
---
 datafusion/physical-expr/src/expressions/lambda.rs | 30 +++++++++++++++++++---
 datafusion/sqllogictest/test_files/async_udf.slt   |  6 +++++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/datafusion/physical-expr/src/expressions/lambda.rs b/datafusion/physical-expr/src/expressions/lambda.rs
index 5e6dca1a62..9275821ae9 100644
--- a/datafusion/physical-expr/src/expressions/lambda.rs
+++ b/datafusion/physical-expr/src/expressions/lambda.rs
@@ -21,6 +21,7 @@ use std::hash::Hash;
 use std::sync::Arc;
 
 use crate::{
+    ScalarFunctionExpr,
     expressions::{Column, LambdaVariable},
     physical_expr::PhysicalExpr,
 };
@@ -61,11 +62,16 @@ impl Hash for LambdaExpr {
 impl LambdaExpr {
     /// Create a new lambda expression with the given parameters and body
     pub fn try_new(params: Vec<String>, body: Arc<dyn PhysicalExpr>) -> Result<Self> {
-        if all_unique(&params) {
-            Ok(Self::new(params, body))
-        } else {
-            plan_err!("lambda params must be unique, got ({})", params.join(", "))
+        if !all_unique(&params) {
+            return plan_err!(
+                "lambda params must be unique, got ({})",
+                params.join(", ")
+            );
         }
+
+        check_async_udf(&body)?;
+
+        Ok(Self::new(params, body))
     }
 
     fn new(params: Vec<String>, body: Arc<dyn PhysicalExpr>) -> Self {
@@ -179,6 +185,8 @@ impl PhysicalExpr for LambdaExpr {
             );
         };
 
+        check_async_udf(body)?;
+
         Ok(Arc::new(Self::new(self.params.clone(), Arc::clone(body))))
     }
 
@@ -210,6 +218,20 @@ fn all_unique(params: &[String]) -> bool {
     }
 }
 
+fn check_async_udf(body: &Arc<dyn PhysicalExpr>) -> Result<()> {
+    if body.exists(|expr| {
+        Ok(expr
+            .downcast_ref::<ScalarFunctionExpr>()
+            .is_some_and(|udf| udf.fun().as_async().is_some()))
+    })? {
+        return plan_err!(
+            "Async functions in lambdas aren't supported, see https://github.com/apache/datafusion/issues/22091"
+        );
+    }
+
+    Ok(())
+}
+
 #[cfg(test)]
 mod tests {
     use crate::expressions::{NoOp, lambda::lambda};
diff --git a/datafusion/sqllogictest/test_files/async_udf.slt b/datafusion/sqllogictest/test_files/async_udf.slt
index 0708b59e51..683c2a13e6 100644
--- a/datafusion/sqllogictest/test_files/async_udf.slt
+++ b/datafusion/sqllogictest/test_files/async_udf.slt
@@ -99,3 +99,9 @@ physical_plan
 01)ProjectionExec: expr=[__async_fn_0@1 as async_abs(data.x)]
 02)--AsyncFuncExec: async_expr=[async_expr(name=__async_fn_0, expr=async_abs(x@0))]
 03)----DataSourceExec: partitions=1, partition_sizes=[1]
+
+# Async udf can't be used in lambdas
+query error
+select array_transform([1], v -> async_abs(v));
+----
+DataFusion error: Error during planning: Async functions in lambdas aren't supported, see https://github.com/apache/datafusion/issues/22091


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org