[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!

How about merging these two `if` statements into 1 with `&&`?