diff --git a/pkg/planner/core/rule_eliminate_projection.go b/pkg/planner/core/rule_eliminate_projection.go index d1a7882a22075..e5c586741ab6c 100644 --- a/pkg/planner/core/rule_eliminate_projection.go +++ b/pkg/planner/core/rule_eliminate_projection.go @@ -131,7 +131,11 @@ func doPhysicalProjectionElimination(p PhysicalPlan) PhysicalPlan { } child := p.Children()[0] if childProj, ok := child.(*PhysicalProjection); ok { - childProj.SetSchema(p.Schema()) + // when current projection is an empty projection(schema pruned by column pruner), no need to reset child's schema + // TODO: avoid producing empty projection in column pruner. + if p.Schema().Len() != 0 { + childProj.SetSchema(p.Schema()) + } } for i, col := range p.Schema().Columns { if p.SCtx().GetSessionVars().StmtCtx.ColRefFromUpdatePlan.Has(int(col.UniqueID)) && !child.Schema().Columns[i].Equal(nil, col) {