Class TransformCorrelatedScalarSubquery
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.TransformCorrelatedScalarSubquery
-
- All Implemented Interfaces:
Rule<CorrelatedJoinNode>
public class TransformCorrelatedScalarSubquery extends Object implements Rule<CorrelatedJoinNode>
Scalar filter scan query is something like:SELECT a,b,c FROM rel WHERE a = correlated1 AND b = correlated2This optimizer can rewrite to mark distinct and filter over a left outer join:
From:
- CorrelatedJoin (with correlation list: [C]) - (input) plan which produces symbols: [A, B, C] - (scalar subquery) Project F - Filter(D = C AND E > 5) - plan which produces symbols: [D, E, F]to:- Filter(CASE isDistinct WHEN true THEN true ELSE fail('Scalar sub-query has returned multiple rows')) - MarkDistinct(isDistinct) - CorrelatedJoin (with correlation list: [C]) - AssignUniqueId(adds symbol U) - (input) plan which produces symbols: [A, B, C] - non scalar subqueryThis must be run after aggregation decorrelation rules.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result
-
-
Constructor Summary
Constructors Constructor Description TransformCorrelatedScalarSubquery(Metadata metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rule.Resultapply(CorrelatedJoinNode correlatedJoinNode, Captures captures, Rule.Context context)Pattern<CorrelatedJoinNode>getPattern()Returns a pattern to which plan nodes this rule applies.
-
-
-
Constructor Detail
-
TransformCorrelatedScalarSubquery
public TransformCorrelatedScalarSubquery(Metadata metadata)
-
-
Method Detail
-
getPattern
public Pattern<CorrelatedJoinNode> getPattern()
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<CorrelatedJoinNode>
-
apply
public Rule.Result apply(CorrelatedJoinNode correlatedJoinNode, Captures captures, Rule.Context context)
- Specified by:
applyin interfaceRule<CorrelatedJoinNode>
-
-