Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ impl ReclusterTableInterpreter {
"range_bound(1000, {sample_size})({cluster_key_str})"
));

hilbert_keys.push(format!("{table}.{cluster_key_str}, []"));
hilbert_keys.push(format!("{cluster_key_str}, []"));
}
let hilbert_keys_str = hilbert_keys.join(", ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ select count() from fuse_snapshot('test_hilbert','t');
----
4

query T
query TTT
select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t');
----
(a, b) hilbert {"partial_block_count":0,"partial_segment_count":0,"stable_block_count":0,"stable_segment_count":0,"total_block_count":4,"total_segment_count":4,"unclustered_block_count":4,"unclustered_segment_count":4}
Expand Down Expand Up @@ -69,7 +69,7 @@ insert into t values(9, 9);
statement ok
alter table t recluster final;

query T
query TTT
select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t');
----
(a, b) hilbert {"partial_block_count":1,"partial_segment_count":1,"stable_block_count":4,"stable_segment_count":2,"total_block_count":5,"total_segment_count":3,"unclustered_block_count":0,"unclustered_segment_count":0}
Expand All @@ -89,15 +89,15 @@ select block_count,row_count from fuse_segment('test_hilbert','t');
statement ok
alter table t cluster by hilbert(b, a);

query T
query TTT
select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t');
----
(b, a) hilbert {"partial_block_count":0,"partial_segment_count":0,"stable_block_count":0,"stable_segment_count":0,"total_block_count":5,"total_segment_count":3,"unclustered_block_count":5,"unclustered_segment_count":3}

statement ok
alter table t recluster final;

query T
query TTT
select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t');
----
(b, a) hilbert {"partial_block_count":0,"partial_segment_count":0,"stable_block_count":5,"stable_segment_count":2,"total_block_count":5,"total_segment_count":2,"unclustered_block_count":0,"unclustered_segment_count":0}
Expand All @@ -106,7 +106,7 @@ select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t');
# force eval as linear clustering by specify columns #
########################################################

query T
query TTT
select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t', 'a,b');
----
(a, b) linear {"average_depth":1.4,"average_overlaps":0.4,"block_depth_histogram":{"00001":3,"00002":2},"constant_block_count":0,"total_block_count":5}
Expand All @@ -122,7 +122,7 @@ statement ok
create or replace table t_linear(a int, b int) cluster by (a, b) row_per_block=2 block_per_segment=2;

# no
query T
query TTT
select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t_linear');
----
(a, b) linear {"average_depth":0.0,"average_overlaps":0.0,"block_depth_histogram":{},"constant_block_count":0,"total_block_count":0}
Expand All @@ -145,7 +145,7 @@ set enable_parallel_multi_merge_sort = 0;
statement ok
alter table t_linear recluster final;

query T
query TTT
select * EXCLUDE(timestamp) from clustering_information('test_hilbert','t_linear');
----
(a, b) linear {"average_depth":1.0,"average_overlaps":0.0,"block_depth_histogram":{"00001":4},"constant_block_count":0,"total_block_count":4}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Copyright 2023 Databend Cloud
##
## Licensed under the Elastic License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## https://www.elastic.co/licensing/elastic-license
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.

statement ok
CREATE OR REPLACE DATABASE test_hilbert_2;

statement ok
use test_hilbert_2

statement ok
create or replace table t(a string, b int) cluster by hilbert(substring(a, 1, 5), b) row_per_block=2 block_size_threshold = 18;

statement ok
insert into t values('b', 2), ('c', 4);

statement ok
insert into t values('a', 3),('d', 1);

statement ok
alter table t recluster final;

query TTT
select cluster_key, type, info from clustering_information('test_hilbert_2','t');
----
(SUBSTRING(a FROM 1 FOR 5), b) hilbert {"partial_block_count":2,"partial_segment_count":1,"stable_block_count":0,"stable_segment_count":0,"total_block_count":2,"total_segment_count":1,"unclustered_block_count":0,"unclustered_segment_count":0}

statement ok
drop table t all;

statement ok
drop database test_hilbert_2;