allisonwang-db commented on code in PR #41316:
URL: https://github.com/apache/spark/pull/41316#discussion_r1227292442
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/python/UserDefinedPythonFunction.scala:
##########
@@ -55,3 +56,36 @@ case class UserDefinedPythonFunction(
}
}
}
+
+/**
+ * A user-defined Python table function. This is used by the Python API.
+ */
+case class UserDefinedPythonTableFunction(
+ name: String,
+ func: PythonFunction,
+ returnType: StructType,
+ udfDeterministic: Boolean) {
+
+ def builder(e: Seq[Expression]): LogicalPlan = {
+ val udtf = PythonUDTF(
+ name = name,
+ func = func,
+ elementSchema = returnType,
+ children = e,
+ udfDeterministic = udfDeterministic)
+ Generate(
+ udtf,
+ unrequiredChildIndex = Nil,
+ outer = false,
+ qualifier = None,
+ generatorOutput = Nil,
+ child = OneRowRelation()
Review Comment:
The child will always be one row relation, but the UDTF can be used together
with LATERAL join, which will be optimized during logical planning:
```
LateralJoin
+- LocalRelation
+- Generate [UDTF]
+- OneRowRelation
```
to
```
Generate [UDTF]
+- LocalRelation
```
--
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]