Class RemoveEmptyExceptBranches

java.lang.Object
io.trino.sql.planner.iterative.rule.RemoveEmptyExceptBranches
All Implemented Interfaces:
Rule<ExceptNode>

public class RemoveEmptyExceptBranches extends Object implements Rule<ExceptNode>
Removes branches from an ExceptNode that are guaranteed to produce 0 rows. A EXCEPT E1 EXCEPT E2 ... EXCEPT En is equivalent to A - (E1 + ... + En). If any of the Ei sets is empty, it can be removed. If only A is left and it's empty, it gets replaced with an empty Values node. Otherwise:
  • a projection to preserve the outputs symbols, in the case of EXCEPT ALL.
  • an aggregation to remove duplicates, in case of EXCEPT DISTINCT