planner: implement BuildKeyInfo of LogicalTopN and LogicalTableDual (#15543)

This commit is contained in:
SeaRise
2020-03-23 20:29:32 -05:00
committed by GitHub
parent b8ea8fc42c
commit e32aba0d70
2 changed files with 17 additions and 1 deletions

View File

@ -111,6 +111,22 @@ func (p *LogicalLimit) BuildKeyInfo(selfSchema *expression.Schema, childSchema [
}
}
// BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (p *LogicalTopN) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
p.baseLogicalPlan.BuildKeyInfo(selfSchema, childSchema)
if p.Count == 1 {
p.maxOneRow = true
}
}
// BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (p *LogicalTableDual) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) {
p.baseLogicalPlan.BuildKeyInfo(selfSchema, childSchema)
if p.RowCount == 1 {
p.maxOneRow = true
}
}
// A bijection exists between columns of a projection's schema and this projection's Exprs.
// Sometimes we need a schema made by expr of Exprs to convert a column in child's schema to a column in this projection's Schema.
func (p *LogicalProjection) buildSchemaByExprs(selfSchema *expression.Schema) *expression.Schema {

View File

@ -169,7 +169,7 @@
"Err": false
},
{
"Best": "Apply{UnionAll{UnionAll{Dual->Projection->Dual->Projection}->Aggr(firstrow(Column#4))->Projection->Dual->Projection}->Dual->Projection->MaxOneRow}->Sort->Projection",
"Best": "Join{UnionAll{UnionAll{Dual->Projection->Dual->Projection}->Aggr(firstrow(Column#4))->Projection->Dual->Projection}->Dual}->Sort->Projection",
"Err": false
}
]