You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Ofir Manor <of...@equalum.io> on 2016/05/26 08:51:14 UTC

Does decimal(6,-2) exists on purpose?

Hi,
was surprised to notice a negative scale on decimal (Spark 1.6.1). To
reproduce:

scala> z.printSchema
root
 |-- price: decimal(6,2) (nullable = true)

scala> val a = z.selectExpr("round(price,-2)")
a: org.apache.spark.sql.DataFrame = [round(price,-2): decimal(6,-2)]


I expected the function to return decimal(6,0)
It doesn't immediately break anything for me, but I'm not performing
additional numeric manipulation on the results.

BTW - thinking about it, both round(price) and round(price,-2) might better
return decimal(4,0), not (6,0).
The input decimal was nnnn.nn and will become just nnnn.

Ofir Manor

Co-Founder & CTO | Equalum

Mobile: +972-54-7801286 | Email: ofir.manor@equalum.io