github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/norm/rules/set.opt (about) 1 # ============================================================================= 2 # set.opt contains normalization rules for set operators. 3 # ============================================================================= 4 5 # EliminateUnionAllLeft replaces a union all with a right side having a 6 # cardinality of zero, with just the left side operand. 7 # 8 # It is possible for the left and right sides of the UnionAll to have column 9 # IDs that are also present in the output columns of the UnionAll, e.g. after 10 # the SplitDisjunction exploration rule has been applied. These columns are 11 # included as passthrough columns in the generated Project because they do not 12 # need to be projected. All other column IDs are added to the ProjectionsExpr. 13 [EliminateUnionAllLeft, Normalize] 14 (UnionAll $left:* $right:* & (HasZeroRows $right) $colmap:*) 15 => 16 (Project 17 $left 18 (ProjectColMapLeft $colmap) 19 (ProjectPassthroughLeft $colmap) 20 ) 21 22 # EliminateUnionAllRight replaces a union all with a left side having a 23 # cardinality of zero, with just the right side operand. 24 # 25 # See the comment above EliminateUnionAllLeft which describes when columns are 26 # projected vs. passed-through. 27 [EliminateUnionAllRight, Normalize] 28 (UnionAll $left:* & (HasZeroRows $left) $right:* $colmap:*) 29 => 30 (Project 31 $right 32 (ProjectColMapRight $colmap) 33 (ProjectPassthroughRight $colmap) 34 )