@@ -62,15 +62,22 @@ func (p *LogicalUnionScan) ExplainInfo() string {
62
62
63
63
// PredicatePushDown implements base.LogicalPlan.<1st> interface.
64
64
func (p * LogicalUnionScan ) PredicatePushDown (predicates []expression.Expression , opt * optimizetrace.LogicalOptimizeOp ) ([]expression.Expression , base.LogicalPlan ) {
65
- if expression .ContainVirtualColumn (predicates ) {
66
- // predicates with virtual columns can't be pushed down to TiKV/TiFlash so they'll be put into a Projection
67
- // below the UnionScan, but the current UnionScan doesn't support placing Projection below it, see #53951.
68
- return predicates , p
65
+ var predicatesWithVCol , predicatesWithoutVCol []expression.Expression
66
+ // predicates with virtual columns can't be pushed down to TiKV/TiFlash so they'll be put into a Projection
67
+ // below the UnionScan, but the current UnionScan doesn't support placing Projection below it, see #53951.
68
+ for _ , expr := range predicates {
69
+ if expression .ContainVirtualColumn ([]expression.Expression {expr }) {
70
+ predicatesWithVCol = append (predicatesWithVCol , expr )
71
+ } else {
72
+ predicatesWithoutVCol = append (predicatesWithoutVCol , expr )
73
+ }
69
74
}
75
+ predicates = predicatesWithoutVCol
70
76
retainedPredicates , _ := p .Children ()[0 ].PredicatePushDown (predicates , opt )
71
77
p .Conditions = make ([]expression.Expression , 0 , len (predicates ))
72
78
p .Conditions = append (p .Conditions , predicates ... )
73
79
// The conditions in UnionScan is only used for added rows, so parent Selection should not be removed.
80
+ retainedPredicates = append (retainedPredicates , predicatesWithVCol ... )
74
81
return retainedPredicates , p
75
82
}
76
83
0 commit comments