AngersZhuuuu commented on a change in pull request #31509:
URL: https://github.com/apache/spark/pull/31509#discussion_r571802245



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
##########
@@ -269,3 +269,62 @@ case class TypeOf(child: Expression) extends 
UnaryExpression {
     defineCodeGen(ctx, ev, _ => 
s"""UTF8String.fromString(${child.dataType.catalogString})""")
   }
 }
+
+@ExpressionDescription(
+  usage = """_FUNC_(expr) - Execute all children and return the last child 
result.""",
+  examples = """
+    Examples:
+      > SELECT _FUNC_(1, 2);
+       2
+      > SELECT _FUNC_(1 + 2, 3 + 4);
+       7
+  """,
+  since = "3.2.0",
+  group = "misc_funcs")
+case class DelegateFunction(children: Seq[Expression]) extends Expression {
+  require(children.nonEmpty, s"$prettyName function requires children is not 
empty.")
+
+  private lazy val lastChild = children.last
+
+  override lazy val deterministic: Boolean = children.forall(_.deterministic)
+  override lazy val resolved: Boolean = children.forall(_.resolved)
+  override def foldable: Boolean = children.forall(_.foldable)
+  override def nullable: Boolean = lastChild.nullable
+  override def dataType: DataType = lastChild.dataType
+
+  override def eval(input: InternalRow): Any = {
+    var result: Any = null
+    children.foreach { child =>
+      result = child.eval(input)
+    }
+    result

Review comment:
       Hmmm how about add a result map and avoid re-compute same child?




----------------------------------------------------------------
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.

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