You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "allisonwang-db (via GitHub)" <gi...@apache.org> on 2025/12/22 18:48:11 UTC

Re: [PR] [SPARK-54776][SQL] Improved the logs message regarding lambda function with SQL UDF [spark]

allisonwang-db commented on code in PR #53542:
URL: https://github.com/apache/spark/pull/53542#discussion_r2640884963


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala:
##########
@@ -1633,6 +1635,25 @@ class SessionCatalog(
       throw UserDefinedFunctionErrors.notAScalarFunction(function.name.nameParts)
     }
     (input: Seq[Expression]) => {
+      // Check if any input contains a lambda variable
+      val hasLambdaVar = input.exists { expr =>
+        expr.find {
+          case _: NamedLambdaVariable => true
+          case _: UnresolvedNamedLambdaVariable => true
+          case _ => false
+        }.isDefined
+      }
+      if (hasLambdaVar) {
+        val formattedInputs = input.map {
+          case v: NamedLambdaVariable => "lambda " + v.name
+          case v: UnresolvedNamedLambdaVariable => "lambda " + v.name
+          case e => e.sql
+        }.mkString(", ")
+        throw new AnalysisException(
+          errorClass = "UNSUPPORTED_FEATURE.LAMBDA_FUNCTION_WITH_SQL_UDF",
+          messageParameters = Map(
+            "funcName" -> ("\"" + function.name.unquotedString + "(" + formattedInputs + ")\"")))
+      }

Review Comment:
   Can we add this in `UserDefinedFunctionErrors`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org