Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add a test for mixing udf and vectorized udf.
  • Loading branch information
ueshin committed Sep 11, 2017
commit 803054e9f30b057e1b194b5625cb6216d865f1d4
9 changes: 9 additions & 0 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3264,6 +3264,15 @@ def test_vectorized_udf_invalid_length(self):
'The length of returned value should be the same as input value'):
df.select(raise_exception()).collect()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a test for mixing udf and vectorized udf?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll add a test.


def test_vectorized_udf_mix_udf(self):
from pyspark.sql.functions import udf
df = self.spark.range(10)
row_by_row_udf = udf(lambda x: x, LongType())
pd_udf = pandas_udf(lambda x: x, LongType())
with QuietTest(self.sc):
with self.assertRaisesRegexp(Exception, 'cannot mix vectorized udf and normal udf'):
df.select(row_by_row_udf(col('id')), pd_udf(col('id'))).collect()


if __name__ == "__main__":
from pyspark.sql.tests import *
Expand Down