[SPARK-2209][SQL] Cast shouldn't do null check twice.

Also took the chance to clean up cast a little bit. Too many arrows on each line before!

Maybe we can simplify this to:

```scala
Try(s.toLong).getOrElse(null)
```

(`s.toLong` throws `NumerFormatException` only.)