Class ImplementExceptDistinctAsUnion
java.lang.Object
io.trino.sql.planner.iterative.rule.ImplementExceptDistinctAsUnion
- All Implemented Interfaces:
Rule<ExceptNode>
Converts EXCEPT DISTINCT queries into UNION ALL..GROUP BY...WHERE
E.g.:
SELECT a FROM foo
EXCEPT 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 = 0;
-
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(ExceptNode node, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.
-
Constructor Details
-
ImplementExceptDistinctAsUnion
-
-
Method Details
-
getPattern
Description copied from interface:RuleReturns a pattern to which plan nodes this rule applies.- Specified by:
getPatternin interfaceRule<ExceptNode>
-
apply
- Specified by:
applyin interfaceRule<ExceptNode>
-