Class ImplementIntersectDistinctAsUnion
- java.lang.Object
-
- io.trino.sql.planner.iterative.rule.ImplementIntersectDistinctAsUnion
-
- All Implemented Interfaces:
Rule<IntersectNode>
public class ImplementIntersectDistinctAsUnion extends Object implements Rule<IntersectNode>
Converts INTERSECT DISTINCT queries into UNION ALL..GROUP BY...WHERE E.g.:SELECT a FROM foo INTERSECT DISTINCT SELECT x FROM bar=>SELECT a FROM ( SELECT a, COUNT(foo_marker) AS foo_count, COUNT(bar_marker) AS bar_count FROM ( SELECT a, true as foo_marker, null as bar_marker FROM foo UNION ALL SELECT x, null as foo_marker, true as bar_marker FROM bar ) T1 GROUP BY a ) T2 WHERE foo_count >= 1 AND bar_count >= 1;
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result
-
-
Constructor Summary
Constructors Constructor Description ImplementIntersectDistinctAsUnion(Metadata metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rule.Resultapply(IntersectNode node, Captures captures, Rule.Context context)Pattern<IntersectNode>getPattern()Returns a pattern to which plan nodes this rule applies.
-
-
-
Constructor Detail
-
ImplementIntersectDistinctAsUnion
public ImplementIntersectDistinctAsUnion(Metadata metadata)
-
-
Method Detail
-
getPattern
public Pattern<IntersectNode> getPattern()
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<IntersectNode>
-
apply
public Rule.Result apply(IntersectNode node, Captures captures, Rule.Context context)
- Specified by:
applyin interfaceRule<IntersectNode>
-
-