[SPARK-4938][SQL] Adding optimization to simplify the filter condition

Adding optimization to simplify the filter condition(https://issues.apache.org/jira/browse/SPARK-4938)