zhengruifeng commented on a change in pull request #27488: 
[SPARK-26580][SQL][ML][FOLLOW-UP] Throw exception when use untyped UDF by 
default
URL: https://github.com/apache/spark/pull/27488#discussion_r380500081
 
 

 ##########
 File path: docs/sql-migration-guide.md
 ##########
 @@ -63,8 +63,8 @@ license: |
 
   - Since Spark 3.0, JSON datasource and JSON function `schema_of_json` infer 
TimestampType from string values if they match to the pattern defined by the 
JSON option `timestampFormat`. Set JSON option `inferTimestamp` to `false` to 
disable such type inferring.
 
-  - In Spark version 2.4 and earlier, if 
`org.apache.spark.sql.functions.udf(Any, DataType)` gets a Scala closure with 
primitive-type argument, the returned UDF will return null if the input values 
is null. Since Spark 3.0, the UDF will return the default value of the Java 
type if the input value is null. For example, `val f = udf((x: Int) => x, 
IntegerType)`, `f($"x")` will return null in Spark 2.4 and earlier if column 
`x` is null, and return 0 in Spark 3.0. This behavior change is introduced 
because Spark 3.0 is built with Scala 2.12 by default.
-
+  - Since Spark 3.0, using `org.apache.spark.sql.functions.udf(AnyRef, 
DataType)` is not allowed by default. Set 
`spark.sql.legacy.allowUntypedScalaUDF` to true to keep using it. But please 
note that, in Spark version 2.4 and earlier, if 
`org.apache.spark.sql.functions.udf(AnyRef, DataType)` gets a Scala closure 
with primitive-type argument, the returned UDF will return null if the input 
values is null. However, since Spark 3.0, the UDF will return the default value 
of the Java type if the input value is null. For example, `val f = udf((x: Int) 
=> x, IntegerType)`, `f($"x")` will return null in Spark 2.4 and earlier if 
column `x` is null, and return 0 in Spark 3.0. This behavior change is 
introduced because Spark 3.0 is built with Scala 2.12 by default.
+    
 
 Review comment:
   nit: remove spaces here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to