spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ofir Manor <>
Subject Does decimal(6,-2) exists on purpose?
Date Thu, 26 May 2016 08:51:14 GMT
was surprised to notice a negative scale on decimal (Spark 1.6.1). To

scala> z.printSchema
 |-- 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:

View raw message