Class ImplementIntersectDistinctAsUnion
java.lang.Object
io.trino.sql.planner.iterative.rule.ImplementIntersectDistinctAsUnion
- All Implemented Interfaces:
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 -
Method Summary
Modifier and TypeMethodDescriptionapply(IntersectNode node, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.
-
Constructor Details
-
ImplementIntersectDistinctAsUnion
-
-
Method Details
-
getPattern
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<IntersectNode>
-
apply
- Specified by:
applyin interfaceRule<IntersectNode>
-