Skip to content

Commit 4a56c6d

Browse files
authored
Merge pull request ClickHouse#92444 from ClickHouse/backport/25.8/92079
Backport ClickHouse#92079 to 25.8: Fix polaris catalog: encode nested namespace
2 parents 9c92165 + 27a910d commit 4a56c6d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Databases/DataLake/RestCatalog.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ std::string correctAPIURI(const std::string & uri)
9292
return std::filesystem::path(uri) / "v1";
9393
}
9494

95+
String encodeNamespaceForURI(const String & namespace_name)
96+
{
97+
String encoded;
98+
for (const auto & ch : namespace_name)
99+
{
100+
if (ch == '.')
101+
encoded += "%1F";
102+
else
103+
encoded.push_back(ch);
104+
}
105+
return encoded;
106+
}
107+
95108
}
96109

97110
std::string RestCatalog::Config::toString() const
@@ -500,7 +513,8 @@ RestCatalog::Namespaces RestCatalog::parseNamespaces(DB::ReadBuffer & buf, const
500513

501514
DB::Names RestCatalog::getTables(const std::string & base_namespace, size_t limit) const
502515
{
503-
const std::string endpoint = std::filesystem::path(NAMESPACES_ENDPOINT) / base_namespace / "tables";
516+
auto encoded_namespace = encodeNamespaceForURI(base_namespace);
517+
const std::string endpoint = std::filesystem::path(NAMESPACES_ENDPOINT) / encoded_namespace / "tables";
504518

505519
auto buf = createReadBuffer(config.prefix / endpoint);
506520
return parseTables(*buf, base_namespace, limit);
@@ -594,7 +608,7 @@ bool RestCatalog::getTableMetadataImpl(
594608
headers.emplace_back("X-Iceberg-Access-Delegation", "vended-credentials");
595609
}
596610

597-
const std::string endpoint = std::filesystem::path(NAMESPACES_ENDPOINT) / namespace_name / "tables" / table_name;
611+
const std::string endpoint = std::filesystem::path(NAMESPACES_ENDPOINT) / encodeNamespaceForURI(namespace_name) / "tables" / table_name;
598612
auto buf = createReadBuffer(config.prefix / endpoint, /* params */{}, headers);
599613

600614
if (buf->eof())

0 commit comments

Comments
 (0)