Skip to content

Commit

Permalink
This is an automated cherry-pick of #54609
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
qw4990 authored and ti-chi-bot committed Jul 15, 2024
1 parent ae394c6 commit 7ff1cb7
Show file tree
Hide file tree
Showing 7 changed files with 487 additions and 23 deletions.
78 changes: 78 additions & 0 deletions pkg/planner/core/casetest/mpp/testdata/integration_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
" │ └─ExchangeSender 2.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST",
" │ └─Selection 2.00 mpp[tiflash] not(isnull(test.d3_t.d3_k))",
" │ └─TableFullScan 2.00 mpp[tiflash] table:d3_t pushed down filter:empty, keep order:false",
<<<<<<< HEAD
" └─HashJoin(Probe) 8.00 mpp[tiflash] inner join, equal:[eq(test.fact_t.d2_k, test.d2_t.d2_k)]",
" ├─ExchangeReceiver(Build) 2.00 mpp[tiflash] ",
" │ └─ExchangeSender 2.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST",
Expand All @@ -40,6 +41,22 @@
" │ └─TableFullScan 2.00 mpp[tiflash] table:d1_t pushed down filter:empty, keep order:false",
" └─Selection(Probe) 8.00 mpp[tiflash] not(isnull(test.fact_t.d1_k)), not(isnull(test.fact_t.d2_k)), not(isnull(test.fact_t.d3_k))",
" └─TableFullScan 8.00 mpp[tiflash] table:fact_t pushed down filter:empty, keep order:false"
=======
" └─Projection(Probe) 8.00 mpp[tiflash] test.fact_t.d3_k",
" └─HashJoin 8.00 mpp[tiflash] inner join, equal:[eq(test.fact_t.d2_k, test.d2_t.d2_k)]",
" ├─ExchangeReceiver(Build) 2.00 mpp[tiflash] ",
" │ └─ExchangeSender 2.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST",
" │ └─Selection 2.00 mpp[tiflash] not(isnull(test.d2_t.d2_k))",
" │ └─TableFullScan 2.00 mpp[tiflash] table:d2_t pushed down filter:empty, keep order:false",
" └─Projection(Probe) 8.00 mpp[tiflash] test.fact_t.d2_k, test.fact_t.d3_k",
" └─HashJoin 8.00 mpp[tiflash] inner join, equal:[eq(test.d1_t.d1_k, test.fact_t.d1_k)]",
" ├─ExchangeReceiver(Build) 2.00 mpp[tiflash] ",
" │ └─ExchangeSender 2.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST",
" │ └─Selection 2.00 mpp[tiflash] not(isnull(test.d1_t.d1_k))",
" │ └─TableFullScan 2.00 mpp[tiflash] table:d1_t pushed down filter:empty, keep order:false",
" └─Selection(Probe) 8.00 mpp[tiflash] not(isnull(test.fact_t.d1_k)), not(isnull(test.fact_t.d2_k)), not(isnull(test.fact_t.d3_k))",
" └─TableFullScan 8.00 mpp[tiflash] table:fact_t pushed down filter:empty, keep order:false"
>>>>>>> 9044acbff3a (planner: fix the issue accessing unnecessary table side caused by column pruning (#54609))
]
},
{
Expand Down Expand Up @@ -677,6 +694,7 @@
"└─TableReader 1.00 root MppVersion: 2, data:ExchangeSender",
" └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough",
" └─HashAgg 1.00 mpp[tiflash] funcs:count(1)->Column#18",
<<<<<<< HEAD
" └─HashJoin 128.00 mpp[tiflash] inner join, equal:[eq(test.fact_t.d3_k, test.d3_t.d3_k)]",
" ├─ExchangeReceiver(Build) 4.00 mpp[tiflash] ",
" │ └─ExchangeSender 4.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.d3_t.d3_k, collate: binary]",
Expand All @@ -700,6 +718,34 @@
" └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
" └─Selection 16.00 mpp[tiflash] not(isnull(test.fact_t.d1_k)), not(isnull(test.fact_t.d2_k)), not(isnull(test.fact_t.d3_k))",
" └─TableFullScan 16.00 mpp[tiflash] table:fact_t pushed down filter:empty, keep order:false"
=======
" └─Projection 128.00 mpp[tiflash] test.fact_t.d3_k, test.d3_t.d3_k",
" └─HashJoin 128.00 mpp[tiflash] inner join, equal:[eq(test.fact_t.d3_k, test.d3_t.d3_k)]",
" ├─ExchangeReceiver(Build) 4.00 mpp[tiflash] ",
" │ └─ExchangeSender 4.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.d3_t.d3_k, collate: binary]",
" │ └─Selection 4.00 mpp[tiflash] not(isnull(test.d3_t.d3_k))",
" │ └─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, 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, 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]",
" │ └─Selection 4.00 mpp[tiflash] not(isnull(test.d1_t.d1_k))",
" │ └─TableFullScan 4.00 mpp[tiflash] table:d1_t pushed down filter:empty, keep order:false",
" └─ExchangeReceiver(Probe) 16.00 mpp[tiflash] ",
" └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
" └─Selection 16.00 mpp[tiflash] not(isnull(test.fact_t.d1_k)), not(isnull(test.fact_t.d2_k)), not(isnull(test.fact_t.d3_k))",
" └─TableFullScan 16.00 mpp[tiflash] table:fact_t pushed down filter:empty, keep order:false"
>>>>>>> 9044acbff3a (planner: fix the issue accessing unnecessary table side caused by column pruning (#54609))
]
},
{
Expand Down Expand Up @@ -732,6 +778,7 @@
" │ └─ExchangeSender 4.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.d3_t.value, collate: binary]",
" │ └─Selection 4.00 mpp[tiflash] not(isnull(test.d3_t.value))",
" │ └─TableFullScan 4.00 mpp[tiflash] table:d3_t pushed down filter:empty, keep order:false",
<<<<<<< HEAD
" └─HashJoin(Probe) 64.00 mpp[tiflash] inner join, equal:[eq(test.fact_t.d1_k, test.d2_t.value)]",
" ├─ExchangeReceiver(Build) 4.00 mpp[tiflash] ",
" │ └─ExchangeSender 4.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.d2_t.value, collate: binary]",
Expand All @@ -746,6 +793,24 @@
" └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
" └─Selection 16.00 mpp[tiflash] not(isnull(test.fact_t.d1_k))",
" └─TableFullScan 16.00 mpp[tiflash] table:fact_t pushed down filter:empty, keep order:false"
=======
" └─Projection(Probe) 64.00 mpp[tiflash] test.fact_t.d1_k",
" └─HashJoin 64.00 mpp[tiflash] inner join, equal:[eq(test.fact_t.d1_k, test.d2_t.value)]",
" ├─ExchangeReceiver(Build) 4.00 mpp[tiflash] ",
" │ └─ExchangeSender 4.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.d2_t.value, collate: binary]",
" │ └─Selection 4.00 mpp[tiflash] not(isnull(test.d2_t.value))",
" │ └─TableFullScan 4.00 mpp[tiflash] table:d2_t pushed down filter:empty, keep order:false",
" └─Projection(Probe) 32.00 mpp[tiflash] 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]",
" │ └─Selection 4.00 mpp[tiflash] not(isnull(test.d1_t.d1_k))",
" │ └─TableFullScan 4.00 mpp[tiflash] table:d1_t pushed down filter:empty, keep order:false",
" └─ExchangeReceiver(Probe) 16.00 mpp[tiflash] ",
" └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
" └─Selection 16.00 mpp[tiflash] not(isnull(test.fact_t.d1_k))",
" └─TableFullScan 16.00 mpp[tiflash] table:fact_t pushed down filter:empty, keep order:false"
>>>>>>> 9044acbff3a (planner: fix the issue accessing unnecessary table side caused by column pruning (#54609))
]
},
{
Expand Down Expand Up @@ -831,6 +896,7 @@
" │ └─TableFullScan 4.00 mpp[tiflash] table:d1_t pushed down filter:empty, keep order:false",
" └─Projection(Probe) 102.40 mpp[tiflash] test.fact_t.d1_k",
" └─Selection 102.40 mpp[tiflash] gt(case(isnull(test.fact_t.col1), plus(test.fact_t.col1, 5), 10), 5)",
<<<<<<< HEAD
" └─HashJoin 128.00 mpp[tiflash] right outer join, equal:[eq(test.fact_t.d1_k, test.fact_t.d1_k)]",
" ├─ExchangeReceiver(Build) 16.00 mpp[tiflash] ",
" │ └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
Expand All @@ -840,6 +906,18 @@
" └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
" └─Selection 16.00 mpp[tiflash] not(isnull(test.fact_t.d1_k))",
" └─TableFullScan 16.00 mpp[tiflash] table:t2 pushed down filter:empty, keep order:false"
=======
" └─Projection 128.00 mpp[tiflash] test.fact_t.col1, test.fact_t.d1_k, test.fact_t.col1",
" └─HashJoin 128.00 mpp[tiflash] right outer join, equal:[eq(test.fact_t.d1_k, test.fact_t.d1_k)]",
" ├─ExchangeReceiver(Build) 16.00 mpp[tiflash] ",
" │ └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
" │ └─Selection 16.00 mpp[tiflash] not(isnull(test.fact_t.d1_k))",
" │ └─TableFullScan 16.00 mpp[tiflash] table:t1 pushed down filter:empty, keep order:false",
" └─ExchangeReceiver(Probe) 16.00 mpp[tiflash] ",
" └─ExchangeSender 16.00 mpp[tiflash] ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.fact_t.d1_k, collate: binary]",
" └─Selection 16.00 mpp[tiflash] not(isnull(test.fact_t.d1_k))",
" └─TableFullScan 16.00 mpp[tiflash] table:t2 pushed down filter:empty, keep order:false"
>>>>>>> 9044acbff3a (planner: fix the issue accessing unnecessary table side caused by column pruning (#54609))
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3736,5 +3736,46 @@
"Warning": null
}
]
<<<<<<< HEAD
=======
},
{
"Name": "TestAlwaysTruePredicateWithSubquery",
"Cases": [
{
"SQL": "SHOW ERRORS WHERE TRUE = ALL ( SELECT TRUE GROUP BY 1 LIMIT 1 ) IS NULL IS NOT NULL;",
"Plan": null,
"Warning": null
},
{
"SQL": "explain select * from t WHERE TRUE = ALL ( SELECT TRUE GROUP BY 1 LIMIT 1 ) IS NULL IS NOT NULL;",
"Plan": [
"HashJoin_14 10000.00 root CARTESIAN inner join",
"├─StreamAgg_19(Build) 1.00 root funcs:count(1)->Column#12",
"│ └─Limit_22 1.00 root offset:0, count:1",
"│ └─HashAgg_23 1.00 root group by:1, funcs:firstrow(1)->Column#13",
"│ └─TableDual_24 1.00 root rows:1",
"└─TableReader_17(Probe) 10000.00 root data:TableFullScan_16",
" └─TableFullScan_16 10000.00 cop[tikv] table:t keep order:false, stats:pseudo"
],
"Warning": null
},
{
"SQL": "explain select * from t WHERE TRUE = ALL ( SELECT TRUE from t GROUP BY 1 LIMIT 1 ) is null is not null;",
"Plan": [
"HashJoin_14 10000.00 root CARTESIAN inner join",
"├─StreamAgg_19(Build) 1.00 root funcs:count(1)->Column#15",
"│ └─Limit_22 1.00 root offset:0, count:1",
"│ └─HashAgg_27 1.00 root group by:Column#17, funcs:firstrow(Column#18)->Column#16",
"│ └─TableReader_28 1.00 root data:HashAgg_23",
"│ └─HashAgg_23 1.00 cop[tikv] group by:1, funcs:firstrow(1)->Column#18",
"│ └─TableFullScan_26 10000.00 cop[tikv] table:t keep order:false, stats:pseudo",
"└─TableReader_17(Probe) 10000.00 root data:TableFullScan_16",
" └─TableFullScan_16 10000.00 cop[tikv] table:t keep order:false, stats:pseudo"
],
"Warning": null
}
]
>>>>>>> 9044acbff3a (planner: fix the issue accessing unnecessary table side caused by column pruning (#54609))
}
]
39 changes: 39 additions & 0 deletions pkg/planner/core/casetest/testdata/integration_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -1216,5 +1216,44 @@
]
}
]
<<<<<<< HEAD
=======
},
{
"Name": "TestTiFlashExtraColumnPrune",
"Cases": [
{
"SQL": "explain format = 'brief' select ta.c1 from t1 ta, t1 tb where ta.c1 * ta.c1 > ta.c2 + 10;",
"Plan": [
"TableReader 80000000.00 root MppVersion: 2, data:ExchangeSender",
"└─ExchangeSender 80000000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection 80000000.00 mpp[tiflash] test.t1.c1",
" └─HashJoin 80000000.00 mpp[tiflash] CARTESIAN inner join",
" ├─ExchangeReceiver(Build) 8000.00 mpp[tiflash] ",
" │ └─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST",
" │ └─Projection 8000.00 mpp[tiflash] test.t1.c1",
" │ └─Selection 8000.00 mpp[tiflash] gt(mul(test.t1.c1, test.t1.c1), plus(test.t1.c2, 10))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:ta pushed down filter:empty, keep order:false, stats:pseudo",
" └─TableFullScan(Probe) 10000.00 mpp[tiflash] table:tb keep order:false, stats:pseudo"
]
},
{
"SQL": "explain format = 'brief' select count(*) from t1 ta, t1 tb where ta.c1 * ta.c1 > ta.c2 + 10;",
"Plan": [
"HashAgg 1.00 root funcs:count(Column#9)->Column#7",
"└─TableReader 1.00 root MppVersion: 2, data:ExchangeSender",
" └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough",
" └─HashAgg 1.00 mpp[tiflash] funcs:count(1)->Column#9",
" └─HashJoin 80000000.00 mpp[tiflash] CARTESIAN inner join",
" ├─ExchangeReceiver(Build) 8000.00 mpp[tiflash] ",
" │ └─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST",
" │ └─Projection 8000.00 mpp[tiflash] 1->Column#8",
" │ └─Selection 8000.00 mpp[tiflash] gt(mul(test.t1.c1, test.t1.c1), plus(test.t1.c2, 10))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:ta pushed down filter:empty, keep order:false, stats:pseudo",
" └─TableFullScan(Probe) 10000.00 mpp[tiflash] table:tb keep order:false, stats:pseudo"
]
}
]
>>>>>>> 9044acbff3a (planner: fix the issue accessing unnecessary table side caused by column pruning (#54609))
}
]
20 changes: 20 additions & 0 deletions pkg/planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,26 @@ func TestIssue48257(t *testing.T) {
))
}

func TestIssue54213(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

tk.MustExec(`use test`)
tk.MustExec(`CREATE TABLE tb (
object_id bigint(20),
a bigint(20) ,
b bigint(20) ,
c bigint(20) ,
PRIMARY KEY (object_id),
KEY ab (a,b))`)
tk.MustQuery(`explain select count(1) from (select /*+ force_index(tb, ab) */ 1 from tb where a=1 and b=1 limit 100) a`).Check(
testkit.Rows("StreamAgg_11 1.00 root funcs:count(1)->Column#6",
"└─Limit_12 0.10 root offset:0, count:100",
" └─IndexReader_16 0.10 root index:Limit_15",
" └─Limit_15 0.10 cop[tikv] offset:0, count:100",
" └─IndexRangeScan_14 0.10 cop[tikv] table:tb, index:ab(a, b) range:[1 1,1 1], keep order:false, stats:pseudo"))
}

func TestIssue52472(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
Expand Down
Loading

0 comments on commit 7ff1cb7

Please sign in to comment.