Skip to content

Commit

Permalink
planner: ByItem should filter NULL out pingcap#10488
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Jun 5, 2019
1 parent 97b306b commit f2254c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions planner/core/physical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ func (s *testPlanSuite) TestDAGPlanBuilderSimpleCase(c *C) {
sql: "select * from ((SELECT 1 a,6 b) UNION (SELECT 2,5) UNION (SELECT 2, 4) ORDER BY 1) t order by 1, 2",
best: "UnionAll{Dual->Projection->Dual->Projection->Dual->Projection}->HashAgg->Sort->Sort",
},
{
sql: "select * from (select *, NULL as xxx from t) t order by xxx",
best: "TableReader(Table(t))->Projection",
},
}
for i, tt := range tests {
comment := Commentf("case:%v sql:%s", i, tt.sql)
Expand Down
2 changes: 2 additions & 0 deletions planner/core/rule_column_pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func (ls *LogicalSort) PruneColumns(parentUsedCols []*expression.Column) {
continue
}
ls.ByItems = append(ls.ByItems[:i], ls.ByItems[i+1:]...)
} else if ls.ByItems[i].Expr.GetType().Tp == mysql.TypeNull {
ls.ByItems = append(ls.ByItems[:i], ls.ByItems[i+1:]...)
} else {
parentUsedCols = append(parentUsedCols, cols...)
}
Expand Down

0 comments on commit f2254c9

Please sign in to comment.