SPARK-1589: Fix the incorrect compare