ueshin commented on code in PR #42135:
URL: https://github.com/apache/spark/pull/42135#discussion_r1273976305


##########
python/pyspark/sql/tests/test_udtf.py:
##########
@@ -1214,6 +1217,153 @@ def eval(self, **kwargs):
         ):
             self.spark.sql("SELECT * FROM test_udtf(1, 'x')").collect()
 
+    def test_udtf_with_analyze_using_broadcast(self):
+        colname = self.sc.broadcast("col1")
+
+        @udtf
+        class TestUDTF:
+            @staticmethod
+            def analyze(a: AnalyzeArgument) -> AnalyzeResult:
+                return AnalyzeResult(StructType().add(colname.value, 
a.data_type))
+
+            def eval(self, a):
+                yield a,
+
+        df = TestUDTF(lit(10))
+        assertSchemaEqual(df.schema, StructType().add("col1", IntegerType()))
+        assertDataFrameEqual(df, [Row(col=10)])
+
+    def test_udtf_with_analyze_using_accumulator(self):
+        test_accum = self.sc.accumulator(0)
+
+        @udtf
+        class TestUDTF:
+            @staticmethod
+            def analyze(a: AnalyzeArgument) -> AnalyzeResult:
+                test_accum.add(1)
+                return AnalyzeResult(StructType().add("col1", a.data_type))
+
+            def eval(self, a):
+                test_accum.add(1)
+                yield a,
+
+        df = TestUDTF(lit(10))

Review Comment:
   Yes, let me update the test.



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