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

MCOL-678: Add more tests #3013

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
144 changes: 144 additions & 0 deletions mysql-test/columnstore/basic/r/mcs84_rollup.result
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ INSERT INTO booksales VALUES
('Senegal','non-fiction',2014,64980), ('Senegal','non-fiction',2015,78901),
('Paraguay','fiction',2014,87970), ('Paraguay','fiction',2015,76940),
('Paraguay','non-fiction',2014,8760), ('Paraguay','non-fiction',2015,9030);
CREATE TABLE booksales2 (country2 CHAR(35), genre2 CHAR(15), year2 INT, sales2 INT) ENGINE=Columnstore;
INSERT INTO booksales2 VALUES
('Senegal','fiction',2014,12234), ('Senegal','fiction',2015,15647),
('Senegal','non-fiction',2014,64980), ('Senegal','non-fiction',2015,78901),
('Paraguay','fiction',2014,87970), ('Paraguay','fiction',2015,76940),
('Paraguay','non-fiction',2014,8760), ('Paraguay','non-fiction',2015,9030);
CREATE TABLE booksales3 (country3 CHAR(35), genre3 CHAR(15), year3 INT, sales3 INT);
INSERT INTO booksales3 VALUES
('Senegal','fiction',2014,12234), ('Senegal','fiction',2015,15647),
('Senegal','non-fiction',2014,64980), ('Senegal','non-fiction',2015,78901),
('Paraguay','fiction',2014,87970), ('Paraguay','fiction',2015,76940),
('Paraguay','non-fiction',2014,8760), ('Paraguay','non-fiction',2015,9030);
SELECT year, SUM(sales) FROM booksales GROUP BY year ORDER BY year;
year SUM(sales)
2014 173944
Expand Down Expand Up @@ -56,6 +68,138 @@ Paraguay non-fiction 17790
Senegal NULL 171762
Senegal fiction 27881
Senegal non-fiction 143881
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP;
country year genre SUM(sales)
NULL NULL NULL 354462
Paraguay 2014 NULL 96730
Paraguay 2014 fiction 87970
Paraguay 2014 non-fiction 8760
Paraguay 2015 NULL 85970
Paraguay 2015 fiction 76940
Paraguay 2015 non-fiction 9030
Paraguay NULL NULL 182700
Senegal 2014 NULL 77214
Senegal 2014 fiction 12234
Senegal 2014 non-fiction 64980
Senegal 2015 NULL 94548
Senegal 2015 fiction 15647
Senegal 2015 non-fiction 78901
Senegal NULL NULL 171762
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP limit 4;
country year genre SUM(sales)
NULL NULL NULL 354462
Paraguay 2014 NULL 96730
Paraguay 2015 NULL 85970
Paraguay 2015 fiction 76940
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year DESC, genre WITH ROLLUP;
country year genre SUM(sales)
NULL NULL NULL 354462
Paraguay 2014 NULL 96730
Paraguay 2014 fiction 87970
Paraguay 2014 non-fiction 8760
Paraguay 2015 NULL 85970
Paraguay 2015 fiction 76940
Paraguay 2015 non-fiction 9030
Paraguay NULL NULL 182700
Senegal 2014 NULL 77214
Senegal 2014 fiction 12234
Senegal 2014 non-fiction 64980
Senegal 2015 NULL 94548
Senegal 2015 fiction 15647
Senegal 2015 non-fiction 78901
Senegal NULL NULL 171762
select country, year2, sum(sales2) from booksales b1 join booksales2 b2 on b1.sales=b2.sales2 group by country,year2 WITH ROLLUP;
country year2 sum(sales2)
NULL NULL 354462
Paraguay 2014 96730
Paraguay 2015 85970
Paraguay NULL 182700
Senegal 2014 77214
Senegal 2015 94548
Senegal NULL 171762
select country, year3, sum(sales3) from booksales b1 join booksales3 b3 on b1.sales=b3.sales3 group by country,year3 WITH ROLLUP;
country year3 sum(sales3)
NULL NULL 354462
Paraguay 2014 96730
Paraguay 2015 85970
Paraguay NULL 182700
Senegal 2014 77214
Senegal 2015 94548
Senegal NULL 171762
select country, year, sum(sales) from booksales where country in (select max(country) from booksales) group by country,year WITH ROLLUP;
country year sum(sales)
NULL NULL 171762
Senegal 2014 77214
Senegal 2015 94548
Senegal NULL 171762
select country, year, sum(sales) from booksales where country in (select max(country2) from booksales2) group by country,year WITH ROLLUP;
country year sum(sales)
NULL NULL 171762
Senegal 2014 77214
Senegal 2015 94548
Senegal NULL 171762
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP UNION SELECT country2, year2, genre2, SUM(sales2) FROM booksales2 GROUP BY country2,year2,genre2 WITH ROLLUP;
country year genre SUM(sales)
NULL NULL NULL 354462
Paraguay 2014 NULL 96730
Paraguay 2014 fiction 87970
Paraguay 2014 non-fiction 8760
Paraguay 2015 NULL 85970
Paraguay 2015 fiction 76940
Paraguay 2015 non-fiction 9030
Paraguay NULL NULL 182700
Senegal 2014 NULL 77214
Senegal 2014 fiction 12234
Senegal 2014 non-fiction 64980
Senegal 2015 NULL 94548
Senegal 2015 fiction 15647
Senegal 2015 non-fiction 78901
Senegal NULL NULL 171762
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP UNION all SELECT country3, year3, genre3, SUM(sales3) FROM booksales3 GROUP BY country3,year3,genre3 WITH ROLLUP;
country year genre SUM(sales)
NULL NULL NULL 354462
Paraguay 2014 NULL 96730
Paraguay 2014 fiction 87970
Paraguay 2014 fiction 87970
Paraguay 2014 non-fiction 8760
Paraguay 2014 non-fiction 8760
Paraguay 2015 NULL 85970
Paraguay 2015 fiction 76940
Paraguay 2015 fiction 76940
Paraguay 2015 non-fiction 9030
Paraguay 2015 non-fiction 9030
Paraguay NULL NULL 182700
Senegal 2014 NULL 77214
Senegal 2014 fiction 12234
Senegal 2014 fiction 12234
Senegal 2014 non-fiction 64980
Senegal 2014 non-fiction 64980
Senegal 2015 NULL 94548
Senegal 2015 fiction 15647
Senegal 2015 fiction 15647
Senegal 2015 non-fiction 78901
Senegal 2015 non-fiction 78901
Senegal NULL NULL 171762
select country,year,genre,sum(sales),avg(sales) from (SELECT country, year, genre, sales FROM booksales UNION all SELECT country2, year2, genre2, sales2 FROM booksales2) t1 GROUP BY country,year,genre WITH ROLLUP;
country year genre sum(sales) avg(sales)
Paraguay 2014 fiction 175940 87970.0000
Paraguay 2014 non-fiction 17520 8760.0000
Paraguay 2015 fiction 153880 76940.0000
Paraguay 2015 non-fiction 18060 9030.0000
Senegal 2014 fiction 24468 12234.0000
Senegal 2014 non-fiction 129960 64980.0000
Senegal 2015 fiction 31294 15647.0000
Senegal 2015 non-fiction 157802 78901.0000
select country,year,genre,sum(sales) from (SELECT country, year, genre, sales FROM booksales UNION all SELECT country3, year3, genre3, sales3 FROM booksales3) t1 GROUP BY country,year,genre WITH ROLLUP;
country year genre sum(sales)
Paraguay 2014 fiction 175940
Paraguay 2014 non-fiction 17520
Paraguay 2015 fiction 153880
Paraguay 2015 non-fiction 18060
Senegal 2014 fiction 24468
Senegal 2014 non-fiction 129960
Senegal 2015 fiction 31294
Senegal 2015 non-fiction 157802
SELECT country, genre, SUM(sales) FROM (SELECT country, genre, sales FROM booksales) t1 GROUP BY country, genre WITH ROLLUP;
country genre SUM(sales)
NULL NULL 354462
Expand Down
47 changes: 47 additions & 0 deletions mysql-test/columnstore/basic/t/mcs84_rollup.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ INSERT INTO booksales VALUES
('Paraguay','fiction',2014,87970), ('Paraguay','fiction',2015,76940),
('Paraguay','non-fiction',2014,8760), ('Paraguay','non-fiction',2015,9030);

CREATE TABLE booksales2 (country2 CHAR(35), genre2 CHAR(15), year2 INT, sales2 INT) ENGINE=Columnstore;

INSERT INTO booksales2 VALUES
('Senegal','fiction',2014,12234), ('Senegal','fiction',2015,15647),
('Senegal','non-fiction',2014,64980), ('Senegal','non-fiction',2015,78901),
('Paraguay','fiction',2014,87970), ('Paraguay','fiction',2015,76940),
('Paraguay','non-fiction',2014,8760), ('Paraguay','non-fiction',2015,9030);

CREATE TABLE booksales3 (country3 CHAR(35), genre3 CHAR(15), year3 INT, sales3 INT);

INSERT INTO booksales3 VALUES
('Senegal','fiction',2014,12234), ('Senegal','fiction',2015,15647),
('Senegal','non-fiction',2014,64980), ('Senegal','non-fiction',2015,78901),
('Paraguay','fiction',2014,87970), ('Paraguay','fiction',2015,76940),
('Paraguay','non-fiction',2014,8760), ('Paraguay','non-fiction',2015,9030);

SELECT year, SUM(sales) FROM booksales GROUP BY year ORDER BY year;

# Negative. WITH ROLLUP cannot be used with ORDER BY.
Expand All @@ -43,6 +59,37 @@ SELECT year, SUM(sales) FROM booksales GROUP BY year WITH ROLLUP;
SELECT country, genre, SUM(sales) FROM booksales GROUP BY country, genre WITH ROLLUP;

--sorted_result
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP;

--sorted_result
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP limit 4;

--sorted_result
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year DESC, genre WITH ROLLUP;

--sorted_result
select country, year2, sum(sales2) from booksales b1 join booksales2 b2 on b1.sales=b2.sales2 group by country,year2 WITH ROLLUP;

--sorted_result
select country, year3, sum(sales3) from booksales b1 join booksales3 b3 on b1.sales=b3.sales3 group by country,year3 WITH ROLLUP;

--sorted_result
select country, year, sum(sales) from booksales where country in (select max(country) from booksales) group by country,year WITH ROLLUP;

--sorted_result
select country, year, sum(sales) from booksales where country in (select max(country2) from booksales2) group by country,year WITH ROLLUP;

--sorted_result
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP UNION SELECT country2, year2, genre2, SUM(sales2) FROM booksales2 GROUP BY country2,year2,genre2 WITH ROLLUP;

--sorted_result
SELECT country, year, genre, SUM(sales) FROM booksales GROUP BY country, year, genre WITH ROLLUP UNION all SELECT country3, year3, genre3, SUM(sales3) FROM booksales3 GROUP BY country3,year3,genre3 WITH ROLLUP;

--sorted_result
select country,year,genre,sum(sales),avg(sales) from (SELECT country, year, genre, sales FROM booksales UNION all SELECT country2, year2, genre2, sales2 FROM booksales2) t1 GROUP BY country,year,genre WITH ROLLUP;

--sorted_result
select country,year,genre,sum(sales) from (SELECT country, year, genre, sales FROM booksales UNION all SELECT country3, year3, genre3, sales3 FROM booksales3) t1 GROUP BY country,year,genre WITH ROLLUP;
SELECT country, genre, SUM(sales) FROM (SELECT country, genre, sales FROM booksales) t1 GROUP BY country, genre WITH ROLLUP;

CREATE TABLE three_cols ( key1 INTEGER, key2 INTEGER, value DECIMAL(38)) ENGINE=COLUMNSTORE;
Expand Down