@@ -3516,6 +3516,32 @@ def test_wrong_return_type(self):
35163516 with self .assertRaisesRegexp (Exception , 'Invalid.*type' ):
35173517 df .groupby ('id' ).apply (foo ).sort ('id' ).toPandas ()
35183518
3519+ def test_zero_or_more_than_1_parameters (self ):
3520+ from pyspark .sql .functions import pandas_grouped_udf
3521+ error_str = 'Only 1-arg pandas_grouped_udfs are supported.'
3522+ with QuietTest (self .sc ):
3523+ with self .assertRaisesRegexp (ValueError , error_str ):
3524+ pandas_grouped_udf (lambda : 1 , 'one long' )
3525+ with self .assertRaisesRegexp (ValueError , error_str ):
3526+ @pandas_grouped_udf
3527+ def zero_no_type ():
3528+ return 1
3529+ with self .assertRaisesRegexp (ValueError , error_str ):
3530+ @pandas_grouped_udf ("one long" )
3531+ def zero_with_type ():
3532+ return 1
3533+
3534+ with self .assertRaisesRegexp (ValueError , error_str ):
3535+ pandas_grouped_udf (lambda pdf , x : pdf , 'one long' )
3536+ with self .assertRaisesRegexp (ValueError , error_str ):
3537+ @pandas_grouped_udf
3538+ def zero_no_type (pdf , x ):
3539+ return pdf
3540+ with self .assertRaisesRegexp (ValueError , error_str ):
3541+ @pandas_grouped_udf ("one long" )
3542+ def zero_with_type (pdf , x ):
3543+ return pdf
3544+
35193545 def test_wrong_args (self ):
35203546 from pyspark .sql .functions import udf , pandas_udf , pandas_grouped_udf , sum
35213547 df = self .data
0 commit comments