public class TransformCorrelatedScalarSubquery extends Object implements Rule<LateralJoinNode>
SELECT a,b,c FROM rel WHERE a = correlated1 AND b = correlated2
This optimizer can rewrite to mark distinct and filter over a left outer join:
From:
- LateralJoin (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)
- LateralJoin (with correlation list: [C])
- AssignUniqueId(adds symbol U)
- (input) plan which produces symbols: [A, B, C]
- non scalar subquery
This must be run after TransformCorrelatedScalarAggregationToJoin
Rule.Context, Rule.Result| Constructor and Description |
|---|
TransformCorrelatedScalarSubquery() |
| Modifier and Type | Method and Description |
|---|---|
Rule.Result |
apply(LateralJoinNode lateralJoinNode,
Captures captures,
Rule.Context context) |
Pattern |
getPattern()
Returns a pattern to which plan nodes this rule applies.
|
public Pattern getPattern()
RulegetPattern in interface Rule<LateralJoinNode>public Rule.Result apply(LateralJoinNode lateralJoinNode, Captures captures, Rule.Context context)
apply in interface Rule<LateralJoinNode>Copyright © 2012–2019. All rights reserved.