cloud-fan commented on a change in pull request #26640: [SPARK-30000][SQL] Trim
the string when cast string type to decimals
URL: https://github.com/apache/spark/pull/26640#discussion_r349603578
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -632,7 +632,7 @@ abstract class CastBase extends UnaryExpression with
TimeZoneAwareExpression wit
private[this] def castToDecimal(from: DataType, target: DecimalType): Any =>
Any = from match {
case StringType =>
buildCast[UTF8String](_, s => try {
- changePrecision(Decimal(new JavaBigDecimal(s.toString)), target)
+ changePrecision(Decimal(new JavaBigDecimal(s.toString.trim)), target)
Review comment:
`s.trim.toString` vs `s.toString.trim`, which one is better?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]