Class UnwrapCastInComparison
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet
-
- io.trino.sql.planner.iterative.rule.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'
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet
ExpressionRewriteRuleSet.ExpressionRewriter
-
-
Constructor Summary
Constructors Constructor Description UnwrapCastInComparison(Metadata metadata, TypeOperators typeOperators, TypeAnalyzer typeAnalyzer)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ExpressionunwrapCasts(Session session, Metadata metadata, TypeOperators typeOperators, TypeAnalyzer typeAnalyzer, TypeProvider types, Expression expression)-
Methods inherited from class io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet
aggregationExpressionRewrite, filterExpressionRewrite, joinExpressionRewrite, projectExpressionRewrite, rules, valuesExpressionRewrite
-
-
-
-
Constructor Detail
-
UnwrapCastInComparison
public UnwrapCastInComparison(Metadata metadata, TypeOperators typeOperators, TypeAnalyzer typeAnalyzer)
-
-
Method Detail
-
unwrapCasts
public static Expression unwrapCasts(Session session, Metadata metadata, TypeOperators typeOperators, TypeAnalyzer typeAnalyzer, TypeProvider types, Expression expression)
-
-