mengxr commented on a change in pull request #24643: 
[SPARK-26412][PySpark][SQL] Allow Pandas UDF to take an iterator of pd.Series 
or an iterator of tuple of pd.Series
URL: https://github.com/apache/spark/pull/24643#discussion_r293603693
 
 

 ##########
 File path: python/pyspark/sql/tests/test_pandas_udf_scalar.py
 ##########
 @@ -348,12 +436,47 @@ def test_vectorized_udf_invalid_length(self):
                     'Result vector from pandas_udf was not the required 
length'):
                 df.select(raise_exception(col('id'))).collect()
 
+        @pandas_udf(LongType(), PandasUDFType.SCALAR_ITER)
+        def iter1_raise_exception(it):
+            for _ in it:
+                yield pd.Series(1)
+
+        with QuietTest(self.sc):
+            with self.assertRaisesRegexp(
+                    Exception,
+                    "The number of output rows of pandas iterator UDF should 
be "
+                    "the same with input rows"):
+                df.select(iter1_raise_exception(col('id'))).collect()
+
+        @pandas_udf(LongType(), PandasUDFType.SCALAR_ITER)
+        def iter2_raise_exception(it):
+            if sys.version >= '3':
 
 Review comment:
   minor: if you don't want to deal with 2/3:
   
   ~~~python
   for batch in it:
     yield pd.Series([1] * len(batch))
     break
   ~~~

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to