aokolnychyi commented on code in PR #37749:
URL: https://github.com/apache/spark/pull/37749#discussion_r960072719


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/V2ExpressionUtils.scala:
##########
@@ -105,18 +105,27 @@ object V2ExpressionUtils extends SQLConfHelper with 
Logging {
           TransformExpression(bound, resolvedRefs, Some(numBuckets))
         }
       }
-    case NamedTransform(name, refs)
-        if refs.length == 1 && refs.forall(_.isInstanceOf[NamedReference]) =>
-      val resolvedRefs = refs.map(_.asInstanceOf[NamedReference]).map { r =>
-        resolveRef[NamedExpression](r, query)
-      }
+    case NamedTransform(name, args) =>
+      val catalystArgs = convertTransformArgs(args, query)
       funCatalogOpt.flatMap { catalog =>
-        loadV2FunctionOpt(catalog, name, resolvedRefs).map { bound =>
-          TransformExpression(bound, resolvedRefs)
+        loadV2FunctionOpt(catalog, name, catalystArgs).map { bound =>
+          TransformExpression(bound, catalystArgs)
         }
       }
-    case _ =>
-      throw new AnalysisException(s"Transform $trans is not currently 
supported")
+  }
+
+  private def convertTransformArgs(
+      args: Seq[V2Expression],
+      query: LogicalPlan): Seq[Expression] = {
+    args.map {
+      case r: NamedReference =>
+        resolveRef[NamedExpression](r, query)
+      case l: V2Literal[_] =>
+        Literal.create(l.value, l.dataType)
+      case arg =>
+        throw new AnalysisException(
+          s"Only references and literals are supported as transform arguments: 
$arg")

Review Comment:
   Technically, transform args can be arbitrary V2 expressions but I am not 
sure we want to invest into building a framework for supporting those right now.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to