Skip to content

Commit

Permalink
check whether the column is generated by projection
Browse files Browse the repository at this point in the history
  • Loading branch information
Dousir9 committed Jan 30, 2023
1 parent 882dea3 commit dd9ac2d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions planner/core/rule_topn_push_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ func (p *LogicalProjection) pushDownTopN(topN *LogicalTopN, opt *logicalOptimize
for _, by := range topN.ByItems {
cols := expression.ExtractColumns(by.Expr)
for _, col := range cols {
if p.Schema().Contains(col) && col.ID == 0 {
p.children[0] = p.children[0].pushDownTopN(nil, opt)
return topN.setChild(p, opt)
if col.ID == 0 && p.Schema().Contains(col) {
if !p.children[0].Schema().Contains(col) {
// the column is generated by projection
p.children[0] = p.children[0].pushDownTopN(nil, opt)
return topN.setChild(p, opt)
}
}
}
}
Expand Down

0 comments on commit dd9ac2d

Please sign in to comment.