From 0d13f398b566c7b06303747b117c3d3af0e5c779 Mon Sep 17 00:00:00 2001 From: yibin Date: Fri, 15 Mar 2024 10:05:10 +0800 Subject: [PATCH] Add integration test for div_precision_increment support (#8846) ref pingcap/tiflash#8834 --- .../set_variable_div_precision_increment.test | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/fullstack-test2/variables/set_variable_div_precision_increment.test diff --git a/tests/fullstack-test2/variables/set_variable_div_precision_increment.test b/tests/fullstack-test2/variables/set_variable_div_precision_increment.test new file mode 100644 index 00000000000..c5f38d2d1b5 --- /dev/null +++ b/tests/fullstack-test2/variables/set_variable_div_precision_increment.test @@ -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> 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> 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