Skip to content

Commit dd006cb

Browse files
committed
Code review feedback.
1 parent c2b88ae commit dd006cb

File tree

1 file changed

+3
-5
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+3
-5
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,13 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression {
7878
// Throw away extra if more than 9 decimal places
7979
val periodIdx = s.indexOf(".")
8080
var n = s
81-
if (periodIdx != -1) {
82-
if (n.length() - periodIdx > 9) {
83-
n = n.substring(0, periodIdx + 10)
84-
}
81+
if (periodIdx != -1 && n.length() - periodIdx > 9) {
82+
n = n.substring(0, periodIdx + 10)
8583
}
8684
try Timestamp.valueOf(n) catch { case _: java.lang.IllegalArgumentException => null }
8785
})
8886
case BooleanType =>
89-
buildCast[Boolean](_, b => new Timestamp((if(b) 1 else 0) * 1000))
87+
buildCast[Boolean](_, b => new Timestamp((if (b) 1 else 0) * 1000))
9088
case LongType =>
9189
buildCast[Long](_, l => new Timestamp(l * 1000))
9290
case IntegerType =>

0 commit comments

Comments
 (0)