Skip to content

Commit 462a92a

Browse files
committed
address review comments
1 parent cc309b0 commit 462a92a

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

core/src/main/scala/org/apache/spark/api/python/PythonRunner.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ private[spark] object PythonEvalType {
3939

4040
val SQL_PANDAS_SCALAR_UDF = 200
4141
val SQL_PANDAS_GROUP_MAP_UDF = 201
42+
43+
def toString(pythonEvalType: Int): String = pythonEvalType match {
44+
case NON_UDF => "NON_UDF"
45+
case SQL_BATCHED_UDF => "SQL_BATCHED_UDF"
46+
case SQL_PANDAS_SCALAR_UDF => "SQL_PANDAS_SCALAR_UDF"
47+
case SQL_PANDAS_GROUP_MAP_UDF => "SQL_PANDAS_GROUP_MAP_UDF"
48+
}
4249
}
4350

4451
/**

python/pyspark/sql/tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ def test_nondeterministic_udf(self):
439439
import random
440440
udf_random_col = udf(lambda: int(100 * random.random()), IntegerType()).asNondeterministic()
441441
df = self.spark.createDataFrame([Row(1)]).select(udf_random_col().alias('RAND'))
442-
random.seed(1234)
443442
udf_add_ten = udf(lambda rand: rand + 10, IntegerType())
444443
[row] = df.withColumn('RAND_PLUS_TEN', udf_add_ten('RAND')).collect()
445444
self.assertEqual(row[0] + 10, row[1])

python/pyspark/sql/udf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def wrapper(*args):
165165
def asNondeterministic(self):
166166
"""
167167
Updates UserDefinedFunction to nondeterministic.
168+
169+
.. versionadded:: 2.3
168170
"""
169171
self._deterministic = False
170172
return self

sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import scala.reflect.runtime.universe.TypeTag
2323
import scala.util.Try
2424

2525
import org.apache.spark.annotation.InterfaceStability
26+
import org.apache.spark.api.python.PythonEvalType
2627
import org.apache.spark.internal.Logging
2728
import org.apache.spark.sql.api.java._
2829
import org.apache.spark.sql.catalyst.{JavaTypeInference, ScalaReflection}
@@ -58,6 +59,7 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends
5859
| pythonIncludes: ${udf.func.pythonIncludes}
5960
| pythonExec: ${udf.func.pythonExec}
6061
| dataType: ${udf.dataType}
62+
| pythonEvalType: ${PythonEvalType.toString(udf.pythonEvalType)}
6163
| udfDeterministic: ${udf.udfDeterministic}
6264
""".stripMargin)
6365

0 commit comments

Comments
 (0)