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

First steps in moving end to end tests over #15805

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
192 changes: 192 additions & 0 deletions go/test/endtoend/vtgate/queries/aggregation/aggregation.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Copyright 2024 The Vitess Authors.
#
# 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.

create table t3
(
id5 bigint,
id6 bigint,
id7 bigint,
primary key (id5)
) Engine = InnoDB;

create table t3_id7_idx
(
id bigint not null auto_increment,
id7 bigint,
id6 bigint,
primary key (id)
) Engine = InnoDB;

create table t9
(
id1 bigint,
id2 varchar(10),
id3 varchar(10),
primary key (id1)
) ENGINE = InnoDB
DEFAULT charset = utf8mb4
COLLATE = utf8mb4_general_ci;

create table aggr_test
(
id bigint,
val1 varchar(16),
val2 bigint,
primary key (id)
) Engine = InnoDB;

create table aggr_test_dates
(
id bigint,
val1 datetime default current_timestamp,
val2 datetime default current_timestamp,
primary key (id)
) Engine = InnoDB;

create table t7_xxhash
(
uid varchar(50),
phone bigint,
msg varchar(100),
primary key (uid)
) Engine = InnoDB;

create table t7_xxhash_idx
(
phone bigint,
keyspace_id varbinary(50),
primary key (phone, keyspace_id)
) Engine = InnoDB;

CREATE TABLE t1 (
t1_id bigint unsigned NOT NULL,
`name` varchar(20) NOT NULL,
`value` varchar(50),
shardKey bigint,
PRIMARY KEY (t1_id),
UNIQUE KEY `t1id_name` (t1_id, `name`),
KEY `IDX_TA_ValueName` (`value`(20), `name`(10))
) ENGINE InnoDB;

CREATE TABLE t2 (
id bigint NOT NULL,
shardKey bigint,
PRIMARY KEY (id)
) ENGINE InnoDB;

CREATE TABLE t10 (
k BIGINT PRIMARY KEY,
a INT,
b INT
);

CREATE TABLE emp (
empno bigint NOT NULL,
ename VARCHAR(10),
job VARCHAR(9),
mgr bigint,
hiredate DATE,
sal bigint,
comm bigint,
deptno bigint,
PRIMARY KEY (empno)
) Engine = InnoDB
COLLATE = utf8mb4_general_ci;

CREATE TABLE dept (
deptno bigint,
dname VARCHAR(14),
loc VARCHAR(13),
PRIMARY KEY (deptno)
) Engine = InnoDB
COLLATE = utf8mb4_general_ci;

CREATE TABLE bet_logs (
id bigint unsigned NOT NULL,
merchant_game_id bigint unsigned NOT NULL,
bet_amount DECIMAL(20, 8),
game_id bigint,
PRIMARY KEY (id)
) ENGINE InnoDB;

insert into aggr_test(id, val1, val2) values(1,'a',1), (2,'A',1), (3,'b',1), (4,'c',3), (5,'c',4);
insert into aggr_test(id, val1, val2) values(6,'d',null), (7,'e',null), (8,'E',1);

# test types from aggregation
select val1, count(distinct val2), count(*) from aggr_test group by val1;
select val1, sum(distinct val2), sum(val2) from aggr_test group by val1;
select val1, count(distinct val2) k, count(*) from aggr_test group by val1 order by k desc, val1;
select val1, count(distinct val2) k, count(*) from aggr_test group by val1 order by k desc, val1 limit 4;
select ascii(val1) as a, count(*) from aggr_test group by a;
select ascii(val1) as a, count(*) from aggr_test group by a order by a;
select ascii(val1) as a, count(*) from aggr_test group by a order by 2, a;
select val1 as a, count(*) from aggr_test group by a;
select val1 as a, count(*) from aggr_test group by a order by a;
select val1 as a, count(*) from aggr_test group by a order by 2, a;
select sum(val1) from aggr_test;
--skip_if_below_version vtgate 19
select avg(val1) from aggr_test;
--skip_if_below_version vtgate 20
select avg(val2) from aggr_test group by val1 order by val1;

# test ordering and group by int column
insert into t3(id5, id6, id7) values(1,1,2), (2,2,4), (3,2,4), (4,1,2), (5,1,2), (6,3,6);
select id6, id7, count(*) k from t3 group by id6, id7 order by k;
select id6+id7, count(*) k from t3 group by id6+id7 order by k;

# test having by variations
select count(*) as a from aggr_test having 1 = 1;
select count(*) as a from aggr_test having 1 = 1;
select count(*) as a from aggr_test having a = 5;
select count(*) as a from aggr_test having 5 = a;
select count(*) as a from aggr_test having a = a;
select count(*) as a from aggr_test having a = 3+2;
select count(*) as a from aggr_test having 1+4 = 3+2;
select count(*) as a from aggr_test having a = 1;
select count(*) as a from aggr_test having a = "1";
select count(*) as a from aggr_test having a = "5";
select count(*) as a from aggr_test having a = 5.00;
select count(*) as a, val1 from aggr_test group by val1 having a = 1.00;
select 1 from aggr_test having count(*) = 5;
select count(*) as a from aggr_test having a != 5;
select count(*) as a from aggr_test having 5 != a;
select count(*) as a from aggr_test having a != a;
select count(*) as a from aggr_test having a != 3+2;
select count(*) as a from aggr_test having a != 1;
select count(*) as a from aggr_test having a != "1";
select count(*) as a from aggr_test having a != "5";
select count(*) as a from aggr_test having a != 5.00;
select 1 from aggr_test having count(*) != 5;
select count(*) as a from aggr_test having a < 10;
select count(*) as a from aggr_test having 1 < a;
select count(*) as a from aggr_test having a < a;
select count(*) as a from aggr_test having a < 3+2;
select count(*) as a from aggr_test having a < 1;
select count(*) as a from aggr_test having a < "10";
select count(*) as a from aggr_test having a < "5";
select count(*) as a from aggr_test having a < 6.00;
select 1 from aggr_test having count(*) < 5;

# test aggregation on top of joins
select count(*) from aggr_test a join t3 t on a.val2 = t.id7;
select a.val1, count(*) from aggr_test a join t3 t on a.val2 = t.id7 group by a.val1;
select a.val1, count(*) from aggr_test a join t3 t on a.val2 = t.id7 group by a.val1 having count(*) = 4;
select a.val1, count(*) as leCount from aggr_test a join t3 t on a.val2 = t.id7 group by a.val1 having leCount = 4;
select a.val1 from aggr_test a join t3 t on a.val2 = t.id7 group by a.val1 having count(*) = 4;
select max(a1.val2), max(a2.val2), count(*) from aggr_test a1 join aggr_test a2 on a1.val2 = a2.id join t3 t on a2.val2 = t.id7;
select a1.val1, count(distinct a1.val2) from aggr_test a1 join aggr_test a2 on a1.val2 = a2.id join t3 t on a2.val2 = t.id7 group by a1.val1;
--skip_if_below_version vtgate 19
select avg(a1.val2), avg(a2.val2) from aggr_test a1 join aggr_test a2 on a1.val2 = a2.id join t3 t on a2.val2 = t.id7;
--skip_if_below_version vtgate 19
select a1.val1, avg(a1.val2) from aggr_test a1 join aggr_test a2 on a1.val2 = a2.id join t3 t on a2.val2 = t.id7 group by a1.val1;
Loading