Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partition: fix index join probe side will locate partition error when it's a table range scan (#44414) #44422

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4310,6 +4310,9 @@ func (builder *dataReaderBuilder) buildTableReaderForIndexJoin(ctx context.Conte
locateKey[keyColOffsets[i]] = data
}
p, err := pt.GetPartitionByRow(e.ctx, locateKey)
if table.ErrNoPartitionForGivenValue.Equal(err) {
continue
}
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -4354,6 +4357,9 @@ func (builder *dataReaderBuilder) buildTableReaderForIndexJoin(ctx context.Conte
locateKey[keyColOffsets[i]] = data
}
p, err := pt.GetPartitionByRow(e.ctx, locateKey)
if table.ErrNoPartitionForGivenValue.Equal(err) {
continue
}
if err != nil {
return nil, err
}
Expand Down
13 changes: 12 additions & 1 deletion executor/partitiontest/partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ func TestPartitionOnMissing(t *testing.T) {
tk.MustExec(`CREATE TABLE tt1 (
id INT NOT NULL,
listid INT,
name varchar(10)
name varchar(10),
primary key (listid) clustered
)
PARTITION BY LIST (listid) (
PARTITION p1 VALUES IN (1),
Expand Down Expand Up @@ -491,4 +492,14 @@ func TestPartitionOnMissing(t *testing.T) {

tk.MustQuery(`select /*+ inl_join(tt1)*/ count(*) from tt2
left join tt1 on tt1.listid=tt2.listid and tt1.id=tt2.id`).Check(testkit.Rows("5"))
tk.MustQuery(`select /*+ inl_join(tt1)*/ count(*) from tt2
left join tt1 on tt1.listid=tt2.listid`).Check(testkit.Rows("5"))
tk.MustQuery(`explain format = 'brief' select /*+ inl_join(tt1)*/ count(*) from tt2
left join tt1 on tt1.listid=tt2.listid`).Check(testkit.Rows(""+
"StreamAgg 1.00 root funcs:count(1)->Column#7",
"└─IndexJoin 5.00 root left outer join, inner:TableReader, outer key:onmissing.tt2.listid, inner key:onmissing.tt1.listid, equal cond:eq(onmissing.tt2.listid, onmissing.tt1.listid)",
" ├─IndexReader(Build) 5.00 root index:IndexFullScan",
" │ └─IndexFullScan 5.00 cop[tikv] table:tt2, index:idx_listid(listid) keep order:false",
" └─TableReader(Probe) 4.00 root partition:all data:TableRangeScan",
" └─TableRangeScan 4.00 cop[tikv] table:tt1 range: decided by [onmissing.tt2.listid], keep order:false"))
}