From 5e1c10f1e188b7171afb5dd1b225f2a095624d40 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 15 Oct 2023 06:08:08 +0200 Subject: [PATCH] Add a test --- ...indexing_by_space_filling_curves.reference | 2 ++ ...02899_indexing_by_space_filling_curves.sql | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/queries/0_stateless/02899_indexing_by_space_filling_curves.reference create mode 100644 tests/queries/0_stateless/02899_indexing_by_space_filling_curves.sql diff --git a/tests/queries/0_stateless/02899_indexing_by_space_filling_curves.reference b/tests/queries/0_stateless/02899_indexing_by_space_filling_curves.reference new file mode 100644 index 00000000000..75d516255f1 --- /dev/null +++ b/tests/queries/0_stateless/02899_indexing_by_space_filling_curves.reference @@ -0,0 +1,2 @@ +121 +121 diff --git a/tests/queries/0_stateless/02899_indexing_by_space_filling_curves.sql b/tests/queries/0_stateless/02899_indexing_by_space_filling_curves.sql new file mode 100644 index 00000000000..45e71505707 --- /dev/null +++ b/tests/queries/0_stateless/02899_indexing_by_space_filling_curves.sql @@ -0,0 +1,23 @@ +DROP TABLE IF EXISTS test; + +CREATE TABLE test (x UInt32, y UInt32) ENGINE = MergeTree ORDER BY mortonEncode(x, y) SETTINGS index_granularity = 8192, index_granularity_bytes = '1Mi'; +INSERT INTO test SELECT number DIV 1024, number % 1024 FROM numbers(1048576); + +SET max_rows_to_read = 8192, force_primary_key = 1, analyze_index_with_space_filling_curves = 1; +SELECT count() FROM test WHERE x >= 10 AND x <= 20 AND y >= 20 AND y <= 30; + +SET max_rows_to_read = 8192, force_primary_key = 1, analyze_index_with_space_filling_curves = 0; +SELECT count() FROM test WHERE x >= 10 AND x <= 20 AND y >= 20 AND y <= 30; -- { serverError 277 } + +DROP TABLE test; + +-- The same, but with more precise index + +CREATE TABLE test (x UInt32, y UInt32) ENGINE = MergeTree ORDER BY mortonEncode(x, y) SETTINGS index_granularity = 1; +SET max_rows_to_read = 0; +INSERT INTO test SELECT number DIV 32, number % 32 FROM numbers(1024); + +SET max_rows_to_read = 200, force_primary_key = 1, analyze_index_with_space_filling_curves = 1; +SELECT count() FROM test WHERE x >= 10 AND x <= 20 AND y >= 20 AND y <= 30; + +DROP TABLE test;