sven-weber-db commented on code in PR #55611:
URL: https://github.com/apache/spark/pull/55611#discussion_r3190167256


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/externalUDF/MapPartitionExternalUDF.scala:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.catalyst.plans.logical.externalUDF
+
+import org.apache.spark.annotation.Experimental
+import org.apache.spark.sql.catalyst.expressions.{Attribute, 
ExternalUDFExpression}
+import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
+import org.apache.spark.udf.worker.UDFWorkerSpecification
+import org.apache.spark.udf.worker.core.WorkerSessionFactory
+
+/**
+ * :: Experimental ::
+ * Logical plan node for mapPartitions-style UDF execution in an
+ * external worker process.
+ *
+ * @param workerSpec       Specification describing the UDF worker.
+ * @param sessionFactory   Factory for creating worker sessions.
+ * @param functionExpr     The UDF expression describing the function.
+ * @param resultAttributes Output attributes produced by the UDF.
+ * @param child            Input relation whose partitions are processed.
+ */
+@Experimental
+case class MapPartitionExternalUDF(
+    workerSpec: UDFWorkerSpecification,
+    sessionFactory: WorkerSessionFactory,
+    functionExpr: ExternalUDFExpression,

Review Comment:
   > A typical mapPartitions takes just a function, rather than an expression. 
The difference is that:
   
   Thanks for the pointers and explanation. In the initial version, the name 
`Expression` was used wrongly. It should have just been 
`ExternalUserDefinedFunction` - representing a single UDF. I changed this in 
the new version of the PR. `MapPartitions` now receives a single 
`ExternalUserDefinedFunction` instance and there is no sharing anymore with the 
`ExternalUDF` base trait.
   
   >This is not yet connected to pyspark - do we plan to do that in a followup?
   
   Initially, I was planning to do this as a follow-up. I have now extended the 
PR to also include the PySpark Connection with a Flag for `MapInPandas`. Let's 
get this working end-to-end, and then we can extend to other operators.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/externalUDF/ExternalUDF.scala:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.catalyst.plans.logical.externalUDF
+
+import org.apache.spark.annotation.Experimental
+import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeSet, 
ExternalUDFExpression}
+import org.apache.spark.sql.catalyst.plans.logical.UnaryNode
+import org.apache.spark.udf.worker.UDFWorkerSpecification
+
+/**
+ * :: Experimental ::
+ * Base trait for logical plan nodes representing UDFs that are executed
+ * in an external worker process. This covers Python UDFs, and any future
+ * UDF languages that use the language-agnostic UDF worker framework.
+ */
+@Experimental
+trait ExternalUDF extends UnaryNode {
+
+  /** Specification describing how to create and communicate with the UDF 
worker. */
+  def workerSpec: UDFWorkerSpecification
+
+  /** The UDF expression describing the function to execute. */
+  def functionExpr: ExternalUDFExpression

Review Comment:
   Yes, fixed this!



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