Skip to content

Commit 2c76100

Browse files
committed
Makes UDFs work with all types of callables
1 parent b814a12 commit 2c76100

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/pyspark/sql/functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def _create_judf(self):
123123
pickled_command, broadcast_vars, env, includes = _prepare_for_python_RDD(sc, command, self)
124124
ssql_ctx = sc._jvm.SQLContext(sc._jsc.sc())
125125
jdt = ssql_ctx.parseDataType(self.returnType.json())
126-
judf = sc._jvm.UserDefinedPythonFunction(f.__repr__(), bytearray(pickled_command), env,
126+
fname = f.__name__ if hasattr(f, '__name__') else f.__class__.__name__
127+
judf = sc._jvm.UserDefinedPythonFunction(fname, bytearray(pickled_command), env,
127128
includes, sc.pythonExec, broadcast_vars,
128129
sc._javaAccumulator, jdt)
129130
return judf

0 commit comments

Comments
 (0)