File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,10 +120,12 @@ def test_udf_with_callable(self):
120120 d = [Row (number = i , squared = i ** 2 ) for i in range (10 )]
121121 rdd = self .sc .parallelize (d )
122122 data = self .sqlCtx .createDataFrame (rdd )
123+
123124 class PlusFour :
124125 def __call__ (self , col ):
125126 if col is not None :
126127 return col + 4
128+
127129 call = PlusFour ()
128130 pudf = UserDefinedFunction (call , LongType ())
129131 res = data .select (pudf (data ['number' ]).alias ('plus_four' ))
@@ -133,9 +135,11 @@ def test_udf_with_partial_function(self):
133135 d = [Row (number = i , squared = i ** 2 ) for i in range (10 )]
134136 rdd = self .sc .parallelize (d )
135137 data = self .sqlCtx .createDataFrame (rdd )
138+
136139 def some_func (col , param ):
137140 if col is not None :
138141 return col + param
142+
139143 pfunc = functools .partial (some_func , param = 4 )
140144 pudf = UserDefinedFunction (pfunc , LongType ())
141145 res = data .select (pudf (data ['number' ]).alias ('plus_four' ))
You can’t perform that action at this time.
0 commit comments