@@ -40,25 +40,26 @@ import org.apache.spark.sql.types._
4040 *
4141 * Note:
4242 * 1. This rule supports `Add` and `Subtract` in arithmetic expressions.
43- * 2. This rule supports `=`, `>=`, `<=`, `>`, `<`, and `!=` in comparators.
43+ * 2. This rule supports `=` and `!=` in comparators. For `>`, `>=`, `<`, `<=`,
44+ * it may brings inconsistencies after rewrite.
4445 * 3. This rule supports integral-type (`byte`, `short`, `int`, `long`) only.
4546 * It doesn't support `float` or `double` because of precision issues.
4647 */
4748object RewriteArithmeticFiltersOnIntegralColumn extends Rule [LogicalPlan ] with PredicateHelper {
4849 def apply (plan : LogicalPlan ): LogicalPlan = plan transform {
4950 case f : Filter =>
5051 f transformExpressionsUp {
51- case e @ BinaryComparison (left : BinaryArithmetic , right : Expression )
52+ case e @ EqualTo (left : BinaryArithmetic , right : Expression )
5253 if right.foldable && isDataTypeSafe(left.dataType) =>
5354 transformLeft(e, left, right)
54- case e @ BinaryComparison (left : Expression , right : BinaryArithmetic )
55+ case e @ EqualTo (left : Expression , right : BinaryArithmetic )
5556 if left.foldable && isDataTypeSafe(right.dataType) =>
5657 transformRight(e, left, right)
5758 }
5859 }
5960
6061 private def transformLeft (
61- bc : BinaryComparison ,
62+ bc : EqualTo ,
6263 left : BinaryArithmetic ,
6364 right : Expression ): Expression = {
6465 left match {
@@ -75,7 +76,7 @@ object RewriteArithmeticFiltersOnIntegralColumn extends Rule[LogicalPlan] with P
7576 }
7677
7778 private def transformRight (
78- bc : BinaryComparison ,
79+ bc : EqualTo ,
7980 left : Expression ,
8081 right : BinaryArithmetic ): Expression = {
8182 right match {
0 commit comments