Skip to content

Commit

Permalink
This is an automated cherry-pick of #51329
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
time-and-fate authored and ti-chi-bot committed Mar 27, 2024
1 parent ca6a857 commit e8ad174
Show file tree
Hide file tree
Showing 4 changed files with 2,536 additions and 0 deletions.
4 changes: 4 additions & 0 deletions planner/core/logical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,13 @@ type LogicalMaxOneRow struct {
}

// LogicalTableDual represents a dual table plan.
// Note that sometimes we don't set schema for LogicalTableDual (most notably in buildTableDual()), which means
// outputting 0/1 row with zero column. This semantic may be different from your expectation sometimes but should not
// cause any actual problems now.
type LogicalTableDual struct {
logicalSchemaProducer

// RowCount could only be 0 or 1.
RowCount int
}

Expand Down
4 changes: 4 additions & 0 deletions planner/core/rule_predicate_push_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,15 @@ func (p *LogicalProjection) PredicatePushDown(predicates []expression.Expression
return predicates, child
}
}
<<<<<<< HEAD:planner/core/rule_predicate_push_down.go
if len(p.children) == 1 {
if _, isDual := p.children[0].(*LogicalTableDual); isDual {
return predicates, p
}
}
=======
exprCtx := p.SCtx().GetExprCtx()
>>>>>>> 27ce02afd2e (planner: remove the limitation that predicates can't be pushed through `Projection` on `TableDual` (#51329)):pkg/planner/core/rule_predicate_push_down.go
for _, cond := range predicates {
substituted, hasFailed, newFilter := expression.ColumnSubstituteImpl(cond, p.Schema(), p.Exprs, true)
if substituted && !hasFailed && !expression.HasGetSetVarFunc(newFilter) {
Expand Down
Loading

0 comments on commit e8ad174

Please sign in to comment.