spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liancheng <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-7886] Add built-in expressions to Funct...
Date Tue, 09 Jun 2015 08:07:06 GMT
Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6710#discussion_r31990468
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala
---
    @@ -32,9 +38,94 @@ trait FunctionRegistry {
       def conf: CatalystConf
     }
     
    +
    +object FunctionRegistry {
    +
    +  type FunctionBuilder = Seq[Expression] => Expression
    +
    +  val expressions: Map[String, FunctionBuilder] = Map(
    +    // Non aggregate functions
    +    expression[Abs]("abs"),
    +    expression[CreateArray]("array"),
    +    expression[Coalesce]("coalesce"),
    +    expression[Explode]("explode"),
    +    expression[Lower]("lower"),
    +    expression[Substring]("substr"),
    +    expression[Substring]("substring"),
    +    expression[Rand]("rand"),
    +    expression[Randn]("randn"),
    +    expression[CreateStruct]("struct"),
    +    expression[Sqrt]("sqrt"),
    +    expression[Upper]("upper"),
    +
    +    // Math functions
    +    expression[Acos]("acos"),
    +    expression[Asin]("asin"),
    +    expression[Atan]("atan"),
    +    expression[Atan2]("atan2"),
    +    expression[Cbrt]("cbrt"),
    +    expression[Ceil]("ceil"),
    +    expression[Cos]("cos"),
    +    expression[Exp]("exp"),
    +    expression[Expm1]("expm1"),
    +    expression[Floor]("floor"),
    +    expression[Hypot]("hypot"),
    +    expression[Log]("log"),
    +    expression[Log10]("log10"),
    +    expression[Log1p]("log1p"),
    +    expression[Pow]("pow"),
    +    expression[Rint]("rint"),
    +    expression[Signum]("signum"),
    +    expression[Sin]("sin"),
    +    expression[Sinh]("sinh"),
    +    expression[Tan]("tan"),
    +    expression[Tanh]("tanh"),
    +    expression[ToDegrees]("todegrees"),
    +    expression[ToRadians]("toradians"),
    +
    +    // aggregate functions
    +    expression[Average]("avg"),
    +    expression[Count]("count"),
    +    expression[First]("first"),
    +    expression[Last]("last"),
    +    expression[Max]("max"),
    +    expression[Min]("min"),
    +    expression[Sum]("sum")
    +  )
    +
    +  /** See usage above. */
    +  private def expression[T <: Expression](name: String)
    --- End diff --
    
    Should we remove the `name` argument? Seems that we are just using `classOf[T].getName.stripSuffix("$").toLowerCase`
for `name`.


---
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