Github user rxin commented on a diff in the pull request: https://github.com/apache/spark/pull/10845#discussion_r50514078 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala --- @@ -406,6 +406,105 @@ object HiveTypeCoercion { PromotePrecision(Cast(e, dataType)) } + private def binaryOperator(e: Expression): Expression = e match { + case b @ BinaryComparison(e1 @ DecimalType.Expression(p1, s1), + e2 @ DecimalType.Expression(p2, s2)) if p1 != p2 || s1 != s2 => + val resultType = widerDecimalType(p1, s1, p2, s2) + b.makeCopy(Array(Cast(e1, resultType), Cast(e2, resultType))) + + // Strength reduction for comparisons between an integral column and a decimal literal: + // 1. int_col > decimal_literal => int_col > floor(decimal_literal) + // 2. int_col >= decimal_literal => int_col >= ceil(decimal_literal) + // 3. int_col < decimal_literal => int_col < ceil(decimal_literal) + // 4. int_col <= decimal_literal => int_col <= floor(decimal_literal) + // 5. decimal_literal > int_col => ceil(decimal_literal) > int_col + // 6. decimal_literal >= int_col => floor(decimal_literal) >= int_col + // 7. decimal_literal < int_col => floor(decimal_literal) < int_col + // 8. decimal_literal <= int_col => ceil(decimal_literal) <= int_col + case GreaterThan(i @ IntegralType(), Literal(value: Decimal, _: DecimalType)) => + GreaterThan(i, Literal.create(value.floor.toInt, IntegerType)) --- End diff -- i don't think you can just do a toInt here .... decimal scope is larger than int.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org