1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

feat(runtime)!: MCOL-678 A "GROUP BY ... WITH ROLLUP" support

Adds a special column which helps to differentiate data and rollups of
various depts and a simple logic to row aggregation to add processing of
subtotals.
This commit is contained in:
Sergey Zefirov
2023-09-26 17:01:53 +03:00
committed by GitHub
parent 5013717730
commit 920607520c
20 changed files with 650 additions and 74 deletions

View File

@ -29,13 +29,41 @@ SELECT year, SUM(sales) FROM booksales GROUP BY year ORDER BY year;
--error 1221
SELECT year, SUM(sales) FROM booksales GROUP BY year WITH ROLLUP ORDER BY year;
# WITH ROLLUP not supported yet. MCOL-678
--error 1178
--sorted_result
SELECT year, sales, MAX(country) FROM booksales GROUP BY year, sales;
--sorted_result
SELECT year, MAX(country) FROM booksales GROUP BY year;
--sorted_result
SELECT year, sales, MAX(country) FROM booksales GROUP BY year, sales WITH ROLLUP;
--sorted_result
SELECT year, SUM(sales) FROM booksales GROUP BY year WITH ROLLUP;
--error 1178
SELECT year, SUM(sales) FROM booksales GROUP BY year ASC WITH ROLLUP;
--error 1178
SELECT year, SUM(sales) FROM booksales GROUP BY year DESC WITH ROLLUP;
--sorted_result
SELECT country, genre, SUM(sales) FROM booksales GROUP BY country, genre WITH ROLLUP;
CREATE TABLE three_cols ( key1 INTEGER, key2 INTEGER, value DECIMAL(38)) ENGINE=COLUMNSTORE;
INSERT INTO three_cols(key1, key2, value) VALUES
(NULL, NULL, NULL)
, (NULL, NULL, 1)
, (NULL, 1, 2)
, ( 1, 1, 3)
, ( 1, 2, 4)
, ( 1, 2, 5)
, ( 2, 3, 6)
, ( 2, 3, 7);
--sorted_result
SELECT key1, key2, SUM(value), AVG(value), MIN(value), MAX(value), COUNT(value), COUNT(*) FROM three_cols GROUP BY key1, key2 WITH ROLLUP;
--error 1815
SELECT key1, key2, GROUP_CONCAT(value) FROM three_cols GROUP BY key1, key2 WITH ROLLUP;
--error 1815
SELECT key1, key2, JSON_ARRAYAGG(value) FROM three_cols GROUP BY key1, key2 WITH ROLLUP;
--error 1815
SELECT 100, SUM(value) FROM three_cols GROUP BY 1 WITH ROLLUP;
# Clean up
DROP DATABASE IF EXISTS mcs84_db;