Class UnwrapCastInComparison
java.lang.Object
io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet
io.trino.sql.planner.iterative.rule.UnwrapCastInComparison
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
ConstructorsConstructorDescriptionUnwrapCastInComparison(PlannerContext plannerContext, TypeAnalyzer typeAnalyzer) -
Method Summary
Modifier and TypeMethodDescriptionstatic ExpressionfalseIfNotNull(Expression argument) static ExpressiontrueIfNotNull(Expression argument) static ExpressionunwrapCasts(Session session, PlannerContext plannerContext, TypeAnalyzer typeAnalyzer, TypeProvider types, Expression expression) Methods inherited from class io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet
aggregationExpressionRewrite, filterExpressionRewrite, joinExpressionRewrite, patternRecognitionExpressionRewrite, projectExpressionRewrite, rules, valuesExpressionRewrite
-
Constructor Details
-
UnwrapCastInComparison
-
-
Method Details
-
unwrapCasts
public static Expression unwrapCasts(Session session, PlannerContext plannerContext, TypeAnalyzer typeAnalyzer, TypeProvider types, Expression expression) -
falseIfNotNull
-
trueIfNotNull
-