Skip to content

Commit

Permalink
planner: don't force set the Column in physical proj elimination (#45824
Browse files Browse the repository at this point in the history
) (#46133)

close #45804
  • Loading branch information
ti-chi-bot authored Aug 16, 2023
1 parent 1d77dfd commit aecde7c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
9 changes: 0 additions & 9 deletions planner/core/rule_eliminate_projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,7 @@ func eliminatePhysicalProjection(p PhysicalPlan) PhysicalPlan {
}
})

oldSchema := p.Schema()
newRoot := doPhysicalProjectionElimination(p)
newCols := newRoot.Schema().Columns
for i, oldCol := range oldSchema.Columns {
oldCol.Index = newCols[i].Index
oldCol.ID = newCols[i].ID
oldCol.UniqueID = newCols[i].UniqueID
oldCol.VirtualExpr = newCols[i].VirtualExpr
newRoot.Schema().Columns[i] = oldCol
}
return newRoot
}

Expand Down
2 changes: 1 addition & 1 deletion planner/core/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ func (p *LogicalCTE) DeriveStats(_ []*property.StatsInfo, selfSchema *expression
return nil, err
}
}
recurStat := p.cte.recursivePartPhysicalPlan.Stats()
recurStat := p.cte.recursivePartLogicalPlan.statsInfo()
for i, col := range selfSchema.Columns {
p.stats.ColNDVs[col.UniqueID] += recurStat.ColNDVs[p.cte.recursivePartLogicalPlan.Schema().Columns[i].UniqueID]
}
Expand Down
4 changes: 2 additions & 2 deletions planner/core/testdata/plan_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -2225,8 +2225,8 @@
{
"SQL": "with recursive cte(a) as (select 1 union select a from cte) select * from cte; -- recursive cte cannot be inlined",
"Plan": [
"CTEFullScan 1.00 root CTE:cte data:CTE_0",
"CTE_0 1.00 root Recursive CTE",
"CTEFullScan 2.00 root CTE:cte data:CTE_0",
"CTE_0 2.00 root Recursive CTE",
"├─Projection(Seed Part) 1.00 root 1->Column#2",
"│ └─TableDual 1.00 root rows:1",
"└─CTETable(Recursive Part) 1.00 root Scan on CTE_0"
Expand Down

0 comments on commit aecde7c

Please sign in to comment.