From 1467451dcc8c8fad415a3af5ce4039cc483d87a5 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Thu, 1 Aug 2024 20:29:56 +0800 Subject: [PATCH] planner: do not reset child projection's schema (#52836) (#55109) close pingcap/tidb#42587 --- pkg/planner/core/rule_eliminate_projection.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/planner/core/rule_eliminate_projection.go b/pkg/planner/core/rule_eliminate_projection.go index 17f2a13bee210..b54c165ca303b 100644 --- a/pkg/planner/core/rule_eliminate_projection.go +++ b/pkg/planner/core/rule_eliminate_projection.go @@ -132,7 +132,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) {