Skip to content

Commit

Permalink
Use java.math.BigDecimal for casting String to Decimal instead of usi…
Browse files Browse the repository at this point in the history
…ng toDouble.
  • Loading branch information
viirya committed Jun 4, 2015
1 parent 2c4d550 commit 7ced9b0
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -323,7 +323,7 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
private[this] def castToDecimal(from: DataType, target: DecimalType): Any => Any = from match {
case StringType =>
buildCast[UTF8String](_, s => try {
changePrecision(Decimal(s.toString.toDouble), target)
changePrecision(Decimal(new java.math.BigDecimal(s.toString)), target)
} catch {
case _: NumberFormatException => null
})
Expand Down

0 comments on commit 7ced9b0

Please sign in to comment.