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

Add test for tidb/issues/49241 (#8480) #8531

Merged
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions tests/fullstack-test/mpp/apply_with_late_materialization.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2023 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# https://github.com/pingcap/tidb/issues/49241
# Preparation.
mysql> drop table if exists test.t;
mysql> drop table if exists test.t1;
mysql> create table test.t(id int, value int);
mysql> create table test.t1(id int, value int);
mysql> insert into test.t values(10,5),(9,5),(8,5),(7,5),(6,5),(5,5),(4,5),(3,5),(2,5),(1,5);
mysql> insert into test.t1 values(2,5);
# insert more than 8192 rows to make sure late materialization is enabled.
mysql> insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t;
mysql> insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t;
mysql> insert into test.t select * from test.t; insert into test.t select * from test.t; insert into test.t select * from test.t;
mysql> alter table test.t set tiflash replica 1;
mysql> alter table test.t1 set tiflash replica 1;
mysql> analyze table test.t;

func> wait_table test t t1

# Test.

# MPP
mysql> set @@tidb_allow_mpp=1; set @@tidb_opt_enable_late_materialization=1; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5;
+------+
| xx |
+------+
| 5 |
+------+
mysql> set @@tidb_allow_mpp=1; set @@tidb_opt_enable_late_materialization=0; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5;
+------+
| xx |
+------+
| 5 |
+------+

# BatchCop
mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 2; set @@tidb_opt_enable_late_materialization=1; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5;
+------+
| xx |
+------+
| 5 |
+------+
mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 2; set @@tidb_opt_enable_late_materialization=0; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5;
+------+
| xx |
+------+
| 5 |
+------+

# Cop
mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 0; set @@tidb_opt_enable_late_materialization=1; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5;
+------+
| xx |
+------+
| 5 |
+------+
mysql> set @@tidb_allow_mpp=0; set @@tidb_allow_tiflash_cop = 1; set @@tidb_allow_batch_cop = 0; set @@tidb_opt_enable_late_materialization=0; select (select t.value from test.t where t.id = t1.id order by t.value limit 1) xx from test.t1 order by t1.value limit 5;
+------+
| xx |
+------+
| 5 |
+------+

# Clean up.
mysql> drop table if exists test.t;
mysql> drop table if exists test.t1;