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 integration test for div_precision_increment support #8846

Merged
merged 18 commits into from
Mar 15, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2024 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.

## test correctness in simple case
mysql> drop table if exists test.t
mysql> create table test.t (a decimal(3, 1), b decimal(3, 0))
mysql> alter table test.t set tiflash replica 1

func> wait_table test t

mysql> insert into test.t values(11.2,3);
mysql> insert into test.t values(10.1,3);
mysql> insert into test.t values(13.7,3);

mysql> set session tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp = 1; select a/b from test.t;
+---------+
| a/b |
+---------+
| 3.73333 |
| 3.36667 |
| 4.56667 |
+---------+

mysql> mysql> set session tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp = 1; select avg(a) from test.t group by b;
+----------+
| avg(a) |
+----------+
| 11.66667 |
+----------+

mysql> set session tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp = 1; set div_precision_increment = 5; select a/b from test.t;
+----------+
| a/b |
+----------+
| 3.733333 |
| 3.366667 |
| 4.566667 |
+----------+

mysql> mysql> set session tidb_isolation_read_engines='tiflash'; set tidb_enforce_mpp = 1; set div_precision_increment = 5; select avg(a) from test.t group by b;
+-----------+
| avg(a) |
+-----------+
| 11.666667 |
+-----------+

mysql> drop table if exists test.t