spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cloud-fan <...@git.apache.org>
Subject [GitHub] spark pull request #17848: [SPARK-20586] [SQL] Add deterministic to ScalaUDF...
Date Fri, 21 Jul 2017 01:46:43 GMT
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17848#discussion_r128668434
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/UDFRegistration.scala ---
    @@ -130,460 +138,507 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry)
extends
           val version = if (i == 0) "2.3.0" else "1.3.0"
           val funcCall = if (i == 0) "() => func" else "func"
           println(s"""
    -        |/**
    -        | * Register a user-defined function with ${i} arguments.
    -        | * @since $version
    -        | */
    -        |def register(name: String, f: UDF$i[$extTypeArgs], returnType: DataType): Unit
= {
    -        |  val func = f$anyCast.call($anyParams)
    -        |  def builder(e: Seq[Expression]) = if (e.length == $i) {
    -        |    ScalaUDF($funcCall, returnType, e)
    -        |  } else {
    -        |    throw new AnalysisException("Invalid number of arguments for function "
+ name +
    -        |      ". Expected: $i; Found: " + e.length)
    -        |  }
    -        |  functionRegistry.createOrReplaceTempFunction(name, builder)
    -        |}""".stripMargin)
    +         |/**
    +         | * Registers a deterministic user-defined function with ${i} arguments.
    +         | * @since $version
    +         | */
    +         |def register(name: String, f: UDF$i[$extTypeArgs], returnType: DataType): Unit
= {
    +         |  register(name, f, returnType, deterministic = true)
    +         |}
    +         |
    +         |/**
    +         | * Registers a user-defined function with ${i} arguments.
    +         | * @since 2.3.0
    +         | */
    +         |def register(name: String, f: UDF$i[$extTypeArgs], returnType: DataType, deterministic:
Boolean): Unit = {
    --- End diff --
    
    as we have to add new APIs, why not we add a bunch of `def udf(f: UDF1[_, _]): UserDefinedFunction`
instead of a bunch of `def register(name: String, f: UDF$i[$extTypeArgs], returnType: DataType,
deterministic: Boolean)`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message