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/14 08:04:23 UTC

(datafusion) branch gh-readonly-queue/main/pr-22097-7f2f78d48b6d3d6aee2ce2fd29910bb4c11b1012 created (now 4fac70d9b2)

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-7f2f78d48b6d3d6aee2ce2fd29910bb4c11b1012
in repository https://gitbox.apache.org/repos/asf/datafusion.git


      at 4fac70d9b2 Minor: Disallow async function in lambdas (#22097)

This branch includes the following new commits:

     new 4fac70d9b2 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-7f2f78d48b6d3d6aee2ce2fd29910bb4c11b1012
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 4fac70d9b274138b89fef8fce80dcafa378f5891
Author: gstvg <28...@users.noreply.github.com>
AuthorDate: Thu May 14 05:04:02 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
---
 datafusion/physical-expr/src/expressions/lambda.rs | 30 +++++++++++++++++++---
 datafusion/sqllogictest/test_files/async_udf.slt   | 10 ++++++++
 2 files changed, 36 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..678b2f7d8b 100644
--- a/datafusion/sqllogictest/test_files/async_udf.slt
+++ b/datafusion/sqllogictest/test_files/async_udf.slt
@@ -99,3 +99,13 @@ 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]
+
+statement ok
+set datafusion.sql_parser.dialect = databricks;
+
+# Async udf can't be used in lambdas
+query error DataFusion error: Error during planning: Async functions in lambdas aren't supported, see https://github\.com/apache/datafusion/issues/22091
+select array_transform([1], v -> async_abs(v));
+
+statement ok
+set datafusion.sql_parser.dialect = generic;


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