mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
tests: add explicit settings/ORDER BY for in order reading/aggregation
v2: rebase on top of upstream/master v3: fix 01780_column_sparse_full v4: fix 01410_nullable_key_and_index Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
fddd031385
commit
23d4837e0a
@ -24,7 +24,7 @@ $CLICKHOUSE_CLIENT -q "SELECT a FROM m ORDER BY a LIMIT 5"
|
||||
$CLICKHOUSE_CLIENT -q "SELECT a, s FROM m ORDER BY a, s LIMIT 10"
|
||||
|
||||
# Not a single .sql test with max_rows_to_read because it doesn't work with Merge storage
|
||||
rows_read=$($CLICKHOUSE_CLIENT -q "SELECT a FROM m ORDER BY a LIMIT 10 FORMAT JSON" --max_threads=1 --max_block_size=20 | grep "rows_read" | sed 's/[^0-9]*//g')
|
||||
rows_read=$($CLICKHOUSE_CLIENT -q "SELECT a FROM m ORDER BY a LIMIT 10 FORMAT JSON" --max_threads=1 --max_block_size=20 --optimize_read_in_order=1 | grep "rows_read" | sed 's/[^0-9]*//g')
|
||||
|
||||
# Expected number of read rows with a bit margin
|
||||
if [[ $rows_read -lt 500 ]]
|
||||
@ -36,7 +36,7 @@ fi
|
||||
$CLICKHOUSE_CLIENT -q "SELECT '---StorageBuffer---'"
|
||||
$CLICKHOUSE_CLIENT -q "CREATE TABLE buf (a UInt32, s String) engine = Buffer('$CLICKHOUSE_DATABASE', s2, 16, 10, 100, 10000, 1000000, 10000000, 100000000)"
|
||||
$CLICKHOUSE_CLIENT -q "SELECT a, s FROM buf ORDER BY a, s LIMIT 10"
|
||||
rows_read=$($CLICKHOUSE_CLIENT -q "SELECT a FROM buf ORDER BY a LIMIT 10 FORMAT JSON" --max_threads=1 --max_block_size=20 | grep "rows_read" | sed 's/[^0-9]*//g')
|
||||
rows_read=$($CLICKHOUSE_CLIENT -q "SELECT a FROM buf ORDER BY a LIMIT 10 FORMAT JSON" --max_threads=1 --max_block_size=20 --optimize_read_in_order=1 | grep "rows_read" | sed 's/[^0-9]*//g')
|
||||
|
||||
# Expected number of read rows with a bit margin
|
||||
if [[ $rows_read -lt 500 ]]
|
||||
@ -48,7 +48,7 @@ fi
|
||||
$CLICKHOUSE_CLIENT -q "SELECT '---MaterializedView---'"
|
||||
$CLICKHOUSE_CLIENT -q "CREATE MATERIALIZED VIEW mv (a UInt32, s String) engine = MergeTree ORDER BY s SETTINGS min_bytes_for_wide_part = 0 POPULATE AS SELECT a, s FROM s1 WHERE a % 7 = 0"
|
||||
$CLICKHOUSE_CLIENT -q "SELECT a, s FROM mv ORDER BY s LIMIT 10"
|
||||
rows_read=$($CLICKHOUSE_CLIENT -q "SELECT a, s FROM mv ORDER BY s LIMIT 10 FORMAT JSON" --max_threads=1 --max_block_size=20 | grep "rows_read" | sed 's/[^0-9]*//g')
|
||||
rows_read=$($CLICKHOUSE_CLIENT -q "SELECT a, s FROM mv ORDER BY s LIMIT 10 FORMAT JSON" --max_threads=1 --max_block_size=20 --optimize_read_in_order=1 | grep "rows_read" | sed 's/[^0-9]*//g')
|
||||
|
||||
if [[ $rows_read -lt 500 ]]
|
||||
then echo "OK"
|
||||
|
@ -3,11 +3,11 @@ hello 1 3 world
|
||||
9
|
||||
9 (0,1)
|
||||
key tupleElement(argMax(tuple(v1, v2, v3, v4, v5), v1), 1) tupleElement(argMax(tuple(v1, v2, v3, v4, v5), v1), 2) tupleElement(argMax(tuple(v1, v2, v3, v4, v5), v1), 3) tupleElement(argMax(tuple(v1, v2, v3, v4, v5), v1), 4) tupleElement(argMax(tuple(v1, v2, v3, v4, v5), v1), 5)
|
||||
4 10 20 10 20 30
|
||||
3 70 20 10 20 30
|
||||
2 11 20 10 20 30
|
||||
5 10 20 10 20 30
|
||||
1 20 20 10 20 30
|
||||
2 11 20 10 20 30
|
||||
3 70 20 10 20 30
|
||||
4 10 20 10 20 30
|
||||
5 10 20 10 20 30
|
||||
6 10 20 10 20 30
|
||||
7 18 20 10 20 30
|
||||
8 30 20 10 20 30
|
||||
|
@ -6,5 +6,5 @@ select argMax(untuple(x)), min(x) from (select (number, number + 1) as x from nu
|
||||
drop table if exists kv;
|
||||
create table kv (key int, v1 int, v2 int, v3 int, v4 int, v5 int) engine MergeTree order by key;
|
||||
insert into kv values (1, 10, 20, 10, 20, 30), (2, 11, 20, 10, 20, 30), (1, 18, 20, 10, 20, 30), (1, 20, 20, 10, 20, 30), (3, 70, 20, 10, 20, 30), (4, 10, 20, 10, 20, 30), (1, 10, 20, 10, 20, 30), (5, 10, 20, 10, 20, 30), (1, 10, 20, 10, 20, 30), (8, 30, 20, 10, 20, 30), (1, 10, 20, 10, 20, 30), (6, 10, 20, 10, 20, 30), (1, 10, 20, 10, 20, 30), (7, 18, 20, 10, 20, 30), (1, 10, 20, 10, 20, 30), (7, 10, 20, 10, 20, 30), (1, 10, 20, 10, 20, 30), (8, 10, 20, 10, 20, 30), (1, 10, 20, 10, 20, 30);
|
||||
select key, untuple(argMax((* except (key),), v1)) from kv group by key format TSVWithNames;
|
||||
select key, untuple(argMax((* except (key),), v1)) from kv group by key order by key format TSVWithNames;
|
||||
drop table if exists kv;
|
||||
|
@ -6,7 +6,7 @@ INSERT INTO tab VALUES (1,1),(1,2),(1,3),(1,4),(1,5);
|
||||
|
||||
INSERT INTO tab VALUES (2,6),(2,7),(2,8),(2,9),(2,0);
|
||||
|
||||
SELECT * FROM tab ORDER BY x LIMIT 3;
|
||||
SELECT * FROM tab ORDER BY x LIMIT 4;
|
||||
SELECT * FROM tab ORDER BY x LIMIT 3 SETTINGS optimize_read_in_order=1;
|
||||
SELECT * FROM tab ORDER BY x LIMIT 4 SETTINGS optimize_read_in_order=1;
|
||||
|
||||
DROP TABLE IF EXISTS tab;
|
||||
|
@ -1,5 +1,5 @@
|
||||
[0,2,3] id2
|
||||
[1,2,3] id1
|
||||
[0,2,3] id2
|
||||
test [1,2,3,4]
|
||||
2 fre
|
||||
3 jhg
|
||||
|
@ -16,7 +16,8 @@ WITH
|
||||
SELECT arraySort(arrayIntersect(argMax(seqs, create_time), arr1)) AS common, id
|
||||
FROM tags
|
||||
WHERE id LIKE 'id%'
|
||||
GROUP BY id;
|
||||
GROUP BY id
|
||||
ORDER BY id;
|
||||
|
||||
DROP TABLE tags;
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
14 21
|
||||
16 24
|
||||
18 27
|
||||
\N 0
|
||||
\N -1
|
||||
\N -2
|
||||
\N -1
|
||||
\N 0
|
||||
\N 0
|
||||
\N -1
|
||||
\N -2
|
||||
|
@ -3,13 +3,14 @@ DROP TABLE IF EXISTS nullable_key_without_final_mark;
|
||||
DROP TABLE IF EXISTS nullable_minmax_index;
|
||||
|
||||
SET max_threads = 1;
|
||||
SET optimize_read_in_order=0;
|
||||
|
||||
CREATE TABLE nullable_key (k Nullable(int), v int) ENGINE MergeTree ORDER BY k SETTINGS allow_nullable_key = 1, index_granularity = 1;
|
||||
|
||||
INSERT INTO nullable_key SELECT number * 2, number * 3 FROM numbers(10);
|
||||
INSERT INTO nullable_key SELECT NULL, -number FROM numbers(3);
|
||||
|
||||
SELECT * FROM nullable_key ORDER BY k;
|
||||
SELECT * FROM nullable_key ORDER BY k, v;
|
||||
|
||||
SET force_primary_key = 1;
|
||||
SET max_rows_to_read = 3;
|
||||
|
@ -12,7 +12,7 @@ set max_memory_usage='500M';
|
||||
set max_threads=1;
|
||||
set max_block_size=500;
|
||||
|
||||
select key, groupArray(repeat('a', 200)), count() from data_01513 group by key format Null; -- { serverError 241; }
|
||||
select key, groupArray(repeat('a', 200)), count() from data_01513 group by key format Null settings optimize_aggregation_in_order=0; -- { serverError 241; }
|
||||
select key, groupArray(repeat('a', 200)), count() from data_01513 group by key format Null settings optimize_aggregation_in_order=1;
|
||||
-- for WITH TOTALS previous groups should be kept.
|
||||
select key, groupArray(repeat('a', 200)), count() from data_01513 group by key with totals format Null settings optimize_aggregation_in_order=1; -- { serverError 241; }
|
||||
|
@ -8,6 +8,6 @@ ALTER TABLE enum_test MODIFY COLUMN e Enum8('IU' = 1, 'WS' = 2, 'PS' = 3);
|
||||
|
||||
INSERT INTO enum_test SELECT '2020-10-09 00:00:00', 'h1', 'PS' from numbers(1);
|
||||
|
||||
SELECT * FROM enum_test ORDER BY timestamp, e desc;
|
||||
SELECT * FROM enum_test ORDER BY timestamp, e desc SETTINGS optimize_read_in_order=1;
|
||||
|
||||
DROP TABLE IF EXISTS enum_test;
|
||||
|
@ -1,4 +1,5 @@
|
||||
SET optimize_monotonous_functions_in_order_by = 1;
|
||||
SET optimize_read_in_order = 1;
|
||||
|
||||
DROP TABLE IF EXISTS test_order_by;
|
||||
|
||||
|
@ -4,7 +4,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
CLICKHOUSE_CLIENT="$CLICKHOUSE_CLIENT --optimize_move_to_prewhere=1 --convert_query_to_cnf=0"
|
||||
CLICKHOUSE_CLIENT="$CLICKHOUSE_CLIENT --optimize_move_to_prewhere=1 --convert_query_to_cnf=0 --optimize_read_in_order=1"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "drop table if exists test_index"
|
||||
$CLICKHOUSE_CLIENT -q "drop table if exists idx"
|
||||
|
@ -1,4 +1,6 @@
|
||||
SET max_threads=0;
|
||||
SET optimize_read_in_order=1;
|
||||
SET read_in_order_two_level_merge_threshold=100;
|
||||
|
||||
DROP TABLE IF EXISTS t_read_in_order;
|
||||
|
||||
|
@ -7,6 +7,7 @@ SETTINGS index_granularity = 4;
|
||||
INSERT INTO t_max_rows_to_read SELECT number FROM numbers(100);
|
||||
|
||||
SET max_threads = 1;
|
||||
SET optimize_read_in_order = 1;
|
||||
|
||||
SELECT a FROM t_max_rows_to_read WHERE a = 10 SETTINGS max_rows_to_read = 4;
|
||||
|
||||
|
@ -20,7 +20,7 @@ ExpressionTransform × 2
|
||||
ExpressionTransform
|
||||
(ReadFromMergeTree)
|
||||
MergeTreeInOrder 0 → 1
|
||||
explain pipeline select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1;
|
||||
explain pipeline select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1, optimize_aggregation_in_order=0;
|
||||
(Expression)
|
||||
ExpressionTransform × 2
|
||||
(Sorting)
|
||||
@ -103,7 +103,7 @@ select parent_key, child_key, count() from data_02233 group by parent_key, child
|
||||
9 2 3
|
||||
|
||||
0 0 100
|
||||
select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1;
|
||||
select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1, optimize_aggregation_in_order=0;
|
||||
0 0 4
|
||||
0 1 3
|
||||
0 2 3
|
||||
|
@ -8,10 +8,10 @@ SELECT child_key, parent_key, child_key FROM data_02233 GROUP BY parent_key, chi
|
||||
-- { echoOn }
|
||||
insert into data_02233 select number%10, number%3, number from numbers(100);
|
||||
explain pipeline select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1, optimize_aggregation_in_order=1;
|
||||
explain pipeline select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1;
|
||||
explain pipeline select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1, optimize_aggregation_in_order=0;
|
||||
select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1, optimize_aggregation_in_order=1;
|
||||
select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1, optimize_aggregation_in_order=1, max_block_size=1;
|
||||
select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1;
|
||||
select parent_key, child_key, count() from data_02233 group by parent_key, child_key with totals order by parent_key, child_key settings max_threads=1, optimize_aggregation_in_order=0;
|
||||
|
||||
-- fuzzer
|
||||
SELECT child_key, parent_key, child_key FROM data_02233 GROUP BY parent_key, child_key, child_key ORDER BY child_key, parent_key ASC NULLS LAST SETTINGS max_threads = 1, optimize_aggregation_in_order = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user