Skip to content

Commit ea378d6

Browse files
authored
Merge pull request ClickHouse#80660 from Algunenano/metadata_path
Handle missing slash in metadata_path when printing system.tables
2 parents 5705f46 + 1060562 commit ea378d6

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/Storages/MergeTree/MergeTreeData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8134,7 +8134,7 @@ bool MergeTreeData::canUseAdaptiveGranularity() const
81348134

81358135
String MergeTreeData::getFullPathOnDisk(const DiskPtr & disk) const
81368136
{
8137-
return disk->getPath() + relative_data_path;
8137+
return fs::path(disk->getPath()) / relative_data_path;
81388138
}
81398139

81408140

tests/integration/test_merge_tree_s3/configs/config.d/storage_conf.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<access_key_id>minio</access_key_id>
88
<secret_access_key>ClickHouse_Minio_P@ssw0rd</secret_access_key>
99
<s3_max_single_part_upload_size>33554432</s3_max_single_part_upload_size>
10+
<metadata_path>/var/lib/clickhouse/disks/custom_path</metadata_path>
1011
</s3>
1112
<unstable_s3>
1213
<type>s3</type>

tests/integration/test_merge_tree_s3/test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ast
12
import logging
23
import os
34
import time
@@ -1064,3 +1065,21 @@ def test_s3_disk_heavy_write_check_mem(cluster, broken_s3, node_name):
10641065
assert int(result) > 0.8 * memory
10651066

10661067
check_no_objects_after_drop(cluster, node_name=node_name)
1068+
1069+
1070+
@pytest.mark.parametrize("node_name", ["node"])
1071+
def test_metadata_path_works_correctly(cluster, node_name):
1072+
node = cluster.instances[node_name]
1073+
table = "s3_test_metadata_path"
1074+
create_table(node, table)
1075+
1076+
response = node.query(f"SELECT data_paths FROM system.tables WHERE name='{table}'")
1077+
data_paths = ast.literal_eval(response)
1078+
assert len(data_paths) >= 1, list
1079+
1080+
# Verifies that trailing slash is added correctly: https://github.com/ClickHouse/ClickHouse/issues/80647
1081+
found = False
1082+
for path in data_paths:
1083+
found = found or "/custom_path/" in path
1084+
assert found, data_paths
1085+
node.query(f"DROP TABLE IF EXISTS {table}")

0 commit comments

Comments
 (0)