SPARK-1589: Fix the incorrect compare

JIRA: https://issues.apache.org/jira/browse/SPARK-1589