diff --git a/pkg/planner/core/rule_column_pruning.go b/pkg/planner/core/rule_column_pruning.go index d9acd8feef08b..38d0a8875c695 100644 --- a/pkg/planner/core/rule_column_pruning.go +++ b/pkg/planner/core/rule_column_pruning.go @@ -18,6 +18,7 @@ import ( "bytes" "context" "fmt" + "slices" "github.com/pingcap/tidb/pkg/expression" "github.com/pingcap/tidb/pkg/expression/aggregation" @@ -33,7 +34,7 @@ type columnPruner struct { func (*columnPruner) optimize(_ context.Context, lp LogicalPlan, opt *logicalOptimizeOp) (LogicalPlan, bool, error) { planChanged := false - lp, err := lp.PruneColumns(lp.Schema().Columns, opt) + lp, err := lp.PruneColumns(slices.Clone(lp.Schema().Columns), opt) if err != nil { return nil, planChanged, err }