Class UnwrapCastInComparison


  • public class UnwrapCastInComparison
    extends ExpressionRewriteRuleSet
    Given s of type S, a constant expression t of type T, and when an implicit cast exists between S->T, converts expression of the form:
     CAST(s as T) = t
     

    into

     s = CAST(t as S)
     

    For example:

     CAST(x AS bigint) = bigint '1'
     

    turns into

     x = smallint '1'
     

    It can simplify expressions that are known to be true or false, and remove the comparisons altogether. For example, give x::smallint, for an expression like:

     CAST(x AS bigint) > bigint '10000000'