ClickHouse/tests/queries/0_stateless/01780_column_sparse_full.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
3.3 KiB
MySQL
Raw Normal View History

2021-05-19 01:48:46 +00:00
-- This test checks, that common SQL operations work
-- with mixed columns (sparse and full) in table.
DROP TABLE IF EXISTS t_sparse_full;
CREATE TABLE t_sparse_full (id UInt64, u UInt64, s String)
ENGINE = MergeTree ORDER BY id
SETTINGS index_granularity = 32, index_granularity_bytes = '10Mi',
2021-05-19 01:48:46 +00:00
ratio_of_defaults_for_sparse_serialization = 0.1;
SYSTEM STOP MERGES t_sparse_full;
INSERT INTO t_sparse_full
SELECT
number,
if (number % 10 = 0, number, 0),
if (number % 7 = 0, toString(number), '')
FROM numbers(1000);
INSERT INTO t_sparse_full
SELECT
number,
number,
toString(number)
FROM numbers(500);
SELECT name, column, serialization_kind
FROM system.parts_columns WHERE table = 't_sparse_full' AND database = currentDatabase() AND active
ORDER BY name, column;
SELECT id, u FROM t_sparse_full ORDER BY id, u LIMIT 4;
SELECT '======';
SELECT id, u FROM t_sparse_full ORDER BY id, u LIMIT 4 SETTINGS optimize_read_in_order = 0;
SELECT '======';
SELECT id, u, s FROM t_sparse_full ORDER BY u DESC LIMIT 3;
SELECT '======';
SELECT id, u, s FROM t_sparse_full WHERE u != 0 ORDER BY u DESC LIMIT 3;
SELECT '======';
SELECT id % 3 AS k, sum(u) FROM t_sparse_full WHERE u != 0 GROUP BY k ORDER BY k;
SELECT '======';
SELECT uniqExact(u) FROM t_sparse_full WHERE s != '';
SELECT '======';
SELECT toUInt32(s) % 5 AS k, groupUniqArray(u % 4) FROM t_sparse_full WHERE s != '' GROUP BY k ORDER BY k;
SELECT max(range(id % 10)[u]) FROM t_sparse_full;
SELECT '======';
2022-05-17 16:20:50 +00:00
SELECT id, u, s FROM remote('127.0.0.{1,2}', currentDatabase(), t_sparse_full) ORDER BY id, u, s LIMIT 5;
2021-05-19 01:48:46 +00:00
SELECT '======';
SELECT sum(u) FROM t_sparse_full GROUP BY id % 3 AS k WITH TOTALS ORDER BY k;
SELECT '======';
2022-06-17 09:51:39 +00:00
SELECT sum(u) AS value FROM t_sparse_full GROUP BY id % 3 AS k WITH ROLLUP ORDER BY value;
2021-05-19 01:48:46 +00:00
SELECT '======';
2022-06-17 09:51:39 +00:00
SELECT sum(u) AS value FROM t_sparse_full GROUP BY id % 3 AS k WITH CUBE ORDER BY value;
2021-05-19 01:48:46 +00:00
SELECT '======';
SELECT sum(id) FROM t_sparse_full GROUP BY u % 3 AS k ORDER BY k;
SELECT '======';
SELECT count() FROM t_sparse_full WHERE u % 4 = 0;
SELECT '======';
SELECT count() FROM t_sparse_full WHERE u IN (SELECT u FROM t_sparse_full WHERE id % 4 = 2);
SELECT '======';
SELECT DISTINCT u FROM t_sparse_full ORDER BY id LIMIT 5;
SELECT '======';
SELECT id, u, s FROM t_sparse_full INNER JOIN
(
SELECT number * 3 AS u FROM numbers(10)
) AS t1 USING(u) ORDER BY id, u, s LIMIT 5;
SELECT '======';
SELECT id, u, s FROM t_sparse_full FULL JOIN
(
SELECT number * 3 AS u FROM numbers(10)
) AS t1 USING(u) ORDER BY id, u, s LIMIT 5;
SELECT '======';
SELECT id, u, s FROM (SELECT number * 2 AS u FROM numbers(10)) AS t1
INNER JOIN t_sparse_full USING(u) ORDER BY id, u, s LIMIT 5;
SELECT '======';
SELECT id, u, s FROM (SELECT number * 2 AS u FROM numbers(10)) AS t1
2022-02-09 11:23:20 +00:00
FULL JOIN t_sparse_full USING(u) ORDER BY id, u, s LIMIT 5;
2021-05-19 01:48:46 +00:00
SELECT '======';
SELECT id, u, s FROM (SELECT u FROM t_sparse_full) AS t1
FULL JOIN t_sparse_full USING(u) ORDER BY id, u, s LIMIT 5;
SYSTEM START MERGES t_sparse_full;
OPTIMIZE TABLE t_sparse_full FINAL;
2021-11-02 17:44:15 +00:00
SELECT '======';
2021-05-19 01:48:46 +00:00
SELECT column, serialization_kind
FROM system.parts_columns WHERE table = 't_sparse_full' AND database = currentDatabase() AND active
ORDER BY name, column;
2021-11-02 17:44:15 +00:00
SELECT '======';
SELECT id, u, s FROM t_sparse_full ORDER BY u DESC LIMIT 3;
DROP TABLE t_sparse_full;