You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by ueshin <gi...@git.apache.org> on 2018/10/04 05:16:21 UTC

[GitHub] spark pull request #22419: [SPARK-23906][SQL] Add built-in UDF TRUNCATE(numb...

Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22419#discussion_r222539741
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ---
    @@ -1245,3 +1245,27 @@ case class BRound(child: Expression, scale: Expression)
         with Serializable with ImplicitCastInputTypes {
       def this(child: Expression) = this(child, Literal(0))
     }
    +
    +/**
    + * The number truncated to scale decimal places.
    + */
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(number, scale) - Returns number truncated to scale decimal places. " +
    +    "If scale is omitted, then number is truncated to 0 places. " +
    +    "scale can be negative to truncate (make zero) scale digits left of the decimal point.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(1234567891.1234567891, 4);
    +       1234567891.1234
    +      > SELECT _FUNC_(1234567891.1234567891, -4);
    +       1234560000
    +      > SELECT _FUNC_(1234567891.1234567891);
    +       1234567891
    +  """)
    +// scalastyle:on line.size.limit
    +case class Truncate(child: Expression, scale: Expression)
    --- End diff --
    
    Hi @wangyum, can you still extend `trunc`?
    If not, what was the major reason you decided to separate these? Thanks!


---

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