dtenedor commented on code in PR #46234:
URL: https://github.com/apache/spark/pull/46234#discussion_r1585558025


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/python/AnalyzePythonUDTFOnExecutorsExec.scala:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.execution.python
+
+import org.apache.spark.TaskContext
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.{Attribute, 
FunctionTableSubqueryArgumentExpression, GenericInternalRow, PythonUDTF, 
PythonUDTFAnalyzeResult, UnsafeProjection}
+import org.apache.spark.sql.catalyst.parser.CatalystSqlParser
+import org.apache.spark.sql.catalyst.util.GenericArrayData
+import org.apache.spark.sql.execution.SparkPlan
+import org.apache.spark.sql.execution.python.EvalPythonExec.ArgumentMetadata
+import org.apache.spark.sql.types.StructType
+import org.apache.spark.unsafe.types.UTF8String
+
+/**
+ * A physical plan that calls the 'analyze' method of a [[PythonUDTF]] on 
executors, when the
+ * ANALYZE_PYTHON_UDTF SQL function is called in a query.
+ *
+ * @param udtf the user-defined Python function
+ * @param requiredChildOutput the required output of the child plan. It's used 
for omitting data
+ *                            generation that will be discarded next by a 
projection.
+ * @param resultAttrs the output schema of the Python UDTF.
+ * @param child the child plan
+ */
+case class AnalyzePythonUDTFOnExecutorsExec(
+    udtf: PythonUDTF,
+    requiredChildOutput: Seq[Attribute],
+    resultAttrs: Seq[Attribute],
+    child: SparkPlan)
+  extends EvalPythonUDTFExec with PythonSQLMetrics {
+  override def withNewChildInternal(newChild: SparkPlan): 
AnalyzePythonUDTFOnExecutorsExec = {
+    copy(child = newChild)
+  }
+
+  override def evaluate(
+      argMetas: Array[ArgumentMetadata],
+      iter: Iterator[InternalRow],
+      schema: StructType,
+      context: TaskContext): Iterator[Iterator[InternalRow]] = {
+    val tableArgs = 
udtf.children.map(_.isInstanceOf[FunctionTableSubqueryArgumentExpression])
+    val parser = CatalystSqlParser
+    val runner = new UserDefinedPythonTableFunctionAnalyzeRunner(

Review Comment:
   As discussed offline, we need to make this a subclass of `BasePythonRunner`. 
I can look into that.
   



-- 
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-unsubscr...@spark.apache.org

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


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

Reply via email to