Skip to content

Commit

Permalink
planner: Fix projection expression and schema not match error (#52913)
Browse files Browse the repository at this point in the history
ref #52828
  • Loading branch information
yibin87 committed Apr 26, 2024
1 parent e0b6b0c commit c73d6c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,15 +714,15 @@
" │ └─TableFullScan 4.00 mpp[tiflash] table:d3_t pushed down filter:empty, keep order:false",
" └─ExchangeReceiver(Probe) 64.00 mpp[tiflash] ",
" └─ExchangeSender 64.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d3_k, collate: binary]",
" └─Projection 64.00 mpp[tiflash] test.fact_t.d3_k",
" └─Projection 64.00 mpp[tiflash] test.fact_t.d3_k, test.fact_t.d2_k",
" └─HashJoin 64.00 mpp[tiflash] inner join, equal:[eq(test.fact_t.d2_k, test.d2_t.d2_k)]",
" ├─ExchangeReceiver(Build) 4.00 mpp[tiflash] ",
" │ └─ExchangeSender 4.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.d2_t.d2_k, collate: binary]",
" │ └─Selection 4.00 mpp[tiflash] not(isnull(test.d2_t.d2_k))",
" │ └─TableFullScan 4.00 mpp[tiflash] table:d2_t pushed down filter:empty, keep order:false",
" └─ExchangeReceiver(Probe) 32.00 mpp[tiflash] ",
" └─ExchangeSender 32.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d2_k, collate: binary]",
" └─Projection 32.00 mpp[tiflash] test.fact_t.d2_k, test.fact_t.d3_k",
" └─Projection 32.00 mpp[tiflash] test.fact_t.d2_k, test.fact_t.d3_k, test.fact_t.d1_k",
" └─HashJoin 32.00 mpp[tiflash] inner join, equal:[eq(test.d1_t.d1_k, test.fact_t.d1_k)]",
" ├─ExchangeReceiver(Build) 4.00 mpp[tiflash] ",
" │ └─ExchangeSender 4.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.d1_t.d1_k, collate: binary]",
Expand Down Expand Up @@ -1015,7 +1015,7 @@
"TableReader 1.00 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 1.00 mpp[tiflash] Column#13",
" └─Projection 1.00 mpp[tiflash] Column#13",
" └─Projection 1.00 mpp[tiflash] Column#13, Column#23, Column#24",
" └─HashJoin 1.00 mpp[tiflash] left outer join, equal:[eq(test.t3.v1, test.t1.v1) eq(test.t3.v2, test.t1.v2)]",
" ├─ExchangeReceiver(Build) 1.00 mpp[tiflash] ",
" │ └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#23, collate: binary], [name: Column#24, collate: binary]",
Expand Down Expand Up @@ -1045,7 +1045,7 @@
" └─ExchangeReceiver 2.00 mpp[tiflash] ",
" └─ExchangeSender 2.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t2.v1, collate: binary], [name: test.t2.v2, collate: binary]",
" └─HashAgg 2.00 mpp[tiflash] group by:test.t2.v1, test.t2.v2, funcs:count(1)->Column#22",
" └─Projection 2.00 mpp[tiflash] test.t2.v1, test.t2.v2",
" └─Projection 2.00 mpp[tiflash] test.t2.v1, test.t2.v2, test.t1.v1, test.t1.v2",
" └─HashJoin 2.00 mpp[tiflash] left outer join, equal:[eq(test.t1.v1, test.t2.v1) eq(test.t1.v2, test.t2.v2)]",
" ├─ExchangeReceiver(Build) 2.00 mpp[tiflash] ",
" │ └─ExchangeSender 2.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t1.v1, collate: binary], [name: test.t1.v2, collate: binary]",
Expand All @@ -1066,7 +1066,7 @@
" └─HashAgg 1.00 mpp[tiflash] group by:test.t2.v1, test.t2.v2, funcs:count(1)->Column#9, funcs:firstrow(test.t2.v1)->test.t2.v1, funcs:firstrow(test.t2.v2)->test.t2.v2",
" └─ExchangeReceiver 1.00 mpp[tiflash] ",
" └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t2.v1, collate: binary], [name: test.t2.v2, collate: binary]",
" └─Projection 1.00 mpp[tiflash] test.t2.v1, test.t2.v2",
" └─Projection 1.00 mpp[tiflash] test.t2.v1, test.t2.v2, test.t3.v1, test.t3.v2",
" └─HashJoin 1.00 mpp[tiflash] left outer join, equal:[eq(test.t3.v1, test.t2.v1) eq(test.t3.v2, test.t2.v2)]",
" ├─ExchangeReceiver(Build) 1.00 mpp[tiflash] ",
" │ └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t3.v1, collate: binary], [name: test.t3.v2, collate: binary]",
Expand Down Expand Up @@ -1593,7 +1593,7 @@
"TableReader 12500.00 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 12500.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 12500.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c1, test.t.c2, test.t.c3",
" └─Projection 12500.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c1, test.t.c2, test.t.c3",
" └─Projection 12500.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c1, test.t.c2, test.t.c3, Column#14, Column#16",
" └─HashJoin 12500.00 mpp[tiflash] inner join, equal:[eq(Column#13, Column#14) eq(Column#15, Column#16)]",
" ├─ExchangeReceiver(Build) 10000.00 mpp[tiflash] ",
" │ └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#23, collate: binary], [name: Column#24, collate: binary]",
Expand All @@ -1612,7 +1612,7 @@
"TableReader 7976.02 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 7976.02 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 7976.02 mpp[tiflash] test.t.c1, test.t.c2, test.t.c5, Column#7, test.t.c1, test.t.c2, test.t.c3, Column#14",
" └─Projection 7976.02 mpp[tiflash] Column#7, test.t.c1, test.t.c2, test.t.c5, Column#14, test.t.c1, test.t.c2, test.t.c3",
" └─Projection 7976.02 mpp[tiflash] Column#7, test.t.c1, test.t.c2, test.t.c5, Column#14, test.t.c1, test.t.c2, test.t.c3, Column#59, Column#60",
" └─HashJoin 7976.02 mpp[tiflash] inner join, equal:[eq(test.t.c1, test.t.c2) eq(test.t.c2, test.t.c3) eq(test.t.c5, test.t.c1)]",
" ├─ExchangeReceiver(Build) 7976.02 mpp[tiflash] ",
" │ └─ExchangeSender 7976.02 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c1, collate: binary], [name: Column#58, collate: binary], [name: test.t.c5, collate: binary]",
Expand Down Expand Up @@ -1658,7 +1658,7 @@
"TableReader 12462.54 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 12462.54 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 12462.54 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
" └─Projection 12462.54 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
" └─Projection 12462.54 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, Column#19, Column#21, Column#22",
" └─HashJoin 12462.54 mpp[tiflash] inner join, equal:[eq(test.t.c2, test.t.c1) eq(test.t.c3, test.t.c2) eq(test.t.c1, test.t.c3) eq(test.t.c3, test.t.c4) eq(test.t.c5, test.t.c1)]",
" ├─ExchangeReceiver(Build) 9970.03 mpp[tiflash] ",
" │ └─ExchangeSender 9970.03 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.t.c2, collate: binary], [name: Column#18, collate: binary], [name: Column#20, collate: binary], [name: test.t.c3, collate: binary], [name: test.t.c5, collate: binary]",
Expand All @@ -1678,7 +1678,7 @@
"TableReader 12500.00 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 12500.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 12500.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
" └─Projection 12500.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5",
" └─Projection 12500.00 mpp[tiflash] test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, test.t.c1, test.t.c2, test.t.c3, test.t.c4, test.t.c5, Column#14",
" └─HashJoin 12500.00 mpp[tiflash] inner join, equal:[eq(Column#13, Column#14)]",
" ├─ExchangeReceiver(Build) 10000.00 mpp[tiflash] ",
" │ └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#18, collate: binary]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3088,7 +3088,7 @@
"TableReader 8000.00 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 mpp[tiflash] Column#6, Column#5, test.employee.empid, test.employee.deptid, test.employee.salary",
" └─Projection 8000.00 mpp[tiflash] test.employee.empid, test.employee.deptid, test.employee.salary, Column#6, Column#5",
" └─Projection 8000.00 mpp[tiflash] test.employee.empid, test.employee.deptid, test.employee.salary, Column#6, Column#5, Column#26",
" └─HashJoin 8000.00 mpp[tiflash] inner join, equal:[eq(test.employee.deptid, Column#6)]",
" ├─ExchangeReceiver(Build) 6400.00 mpp[tiflash] ",
" │ └─ExchangeSender 6400.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#6, collate: binary]",
Expand All @@ -3114,7 +3114,7 @@
"TableReader 8000.00 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 mpp[tiflash] test.employee.empid, test.employee.deptid, test.employee.salary, Column#10, Column#9",
" └─Projection 8000.00 mpp[tiflash] test.employee.empid, test.employee.deptid, test.employee.salary, Column#10, Column#9",
" └─Projection 8000.00 mpp[tiflash] test.employee.empid, test.employee.deptid, test.employee.salary, Column#10, Column#9, Column#26",
" └─HashJoin 8000.00 mpp[tiflash] inner join, equal:[eq(test.employee.deptid, Column#10)]",
" ├─ExchangeReceiver(Build) 6400.00 mpp[tiflash] ",
" │ └─ExchangeSender 6400.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#10, collate: binary]",
Expand Down
1 change: 1 addition & 0 deletions pkg/planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ func (p *PhysicalHashJoin) attach2TaskForMpp(tasks ...base.Task) base.Task {
proj.SetSchema(p.Schema().Clone())
for _, hashCol := range hashColArray {
if !proj.Schema().Contains(hashCol) {
proj.Exprs = append(proj.Exprs, hashCol)
proj.Schema().Append(hashCol)
}
}
Expand Down

0 comments on commit c73d6c5

Please sign in to comment.