Skip to content

Commit 77e3acf

Browse files
authored
planner: don't force set the Column in physical proj elimination (#45824) (#46132)
close #45804
1 parent 29d459b commit 77e3acf

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

planner/core/casetest/testdata/plan_suite_out.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,8 +3850,8 @@
38503850
{
38513851
"SQL": "with recursive cte(a) as (select 1 union select a from cte) select * from cte; -- recursive cte cannot be inlined",
38523852
"Plan": [
3853-
"CTEFullScan 1.00 root CTE:cte data:CTE_0",
3854-
"CTE_0 1.00 root Recursive CTE",
3853+
"CTEFullScan 2.00 root CTE:cte data:CTE_0",
3854+
"CTE_0 2.00 root Recursive CTE",
38553855
"├─Projection(Seed Part) 1.00 root 1->Column#2",
38563856
"│ └─TableDual 1.00 root rows:1",
38573857
"└─CTETable(Recursive Part) 1.00 root Scan on CTE_0"

planner/core/rule_eliminate_projection.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,7 @@ func eliminatePhysicalProjection(p PhysicalPlan) PhysicalPlan {
144144
}
145145
})
146146

147-
oldSchema := p.Schema()
148147
newRoot := doPhysicalProjectionElimination(p)
149-
newCols := newRoot.Schema().Columns
150-
for i, oldCol := range oldSchema.Columns {
151-
oldCol.Index = newCols[i].Index
152-
oldCol.ID = newCols[i].ID
153-
oldCol.UniqueID = newCols[i].UniqueID
154-
oldCol.VirtualExpr = newCols[i].VirtualExpr
155-
newRoot.Schema().Columns[i] = oldCol
156-
}
157148
return newRoot
158149
}
159150

planner/core/stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ func (p *LogicalCTE) DeriveStats(_ []*property.StatsInfo, selfSchema *expression
11341134
return nil, err
11351135
}
11361136
}
1137-
recurStat := p.cte.recursivePartPhysicalPlan.Stats()
1137+
recurStat := p.cte.recursivePartLogicalPlan.statsInfo()
11381138
for i, col := range selfSchema.Columns {
11391139
p.stats.ColNDVs[col.UniqueID] += recurStat.ColNDVs[p.cte.recursivePartLogicalPlan.Schema().Columns[i].UniqueID]
11401140
}

0 commit comments

Comments
 (0)