You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by we...@apache.org on 2020/03/06 05:12:16 UTC

[spark] branch branch-3.0 updated: [SPARK-31010][SQL][FOLLOW-UP] Deprecate untyped scala UDF

This is an automated email from the ASF dual-hosted git repository.

wenchen pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 5375b40  [SPARK-31010][SQL][FOLLOW-UP] Deprecate untyped scala UDF
5375b40 is described below

commit 5375b40f37cefe6f18f9f943412b60c65fe2f844
Author: yi.wu <yi...@databricks.com>
AuthorDate: Fri Mar 6 13:00:04 2020 +0800

    [SPARK-31010][SQL][FOLLOW-UP] Deprecate untyped scala UDF
    
    ### What changes were proposed in this pull request?
    
    Use scala annotation deprecate to deprecate untyped scala UDF.
    
    ### Why are the changes needed?
    
    After #27488, it's weird to see the untyped scala UDF will fail by default without deprecation.
    
    ### Does this PR introduce any user-facing change?
    
    Yes, user will see the warning:
    ```
    <console>:26: warning: method udf in object functions is deprecated (since 3.0.0): Untyped Scala UDF API is deprecated, please use typed Scala UDF API such as 'def udf[RT: TypeTag](f: Function0[RT]): UserDefinedFunction' instead.
           val myudf = udf(() => Math.random(), DoubleType)
                       ^
    ```
    
    ### How was this patch tested?
    
    Tested manually.
    
    Closes #27794 from Ngone51/deprecate_untyped_scala_udf.
    
    Authored-by: yi.wu <yi...@databricks.com>
    Signed-off-by: Wenchen Fan <we...@databricks.com>
    (cherry picked from commit 587266f887f85bfa2a73a77485ab4db522c6aca1)
    Signed-off-by: Wenchen Fan <we...@databricks.com>
---
 sql/core/src/main/scala/org/apache/spark/sql/functions.scala | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala
index c6e8cf7..7a58957 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala
@@ -4732,6 +4732,8 @@ object functions {
    * @group udf_funcs
    * @since 2.0.0
    */
+  @deprecated("Untyped Scala UDF API is deprecated, please use typed Scala UDF API such as " +
+    "'def udf[RT: TypeTag](f: Function0[RT]): UserDefinedFunction' instead.", "3.0.0")
   def udf(f: AnyRef, dataType: DataType): UserDefinedFunction = {
     if (!SQLConf.get.getConf(SQLConf.LEGACY_ALLOW_UNTYPED_SCALA_UDF)) {
       val errorMsg = "You're using untyped Scala UDF, which does not have the input type " +


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org