55#include " ../internal/http_client.h"
66#include " ../internal/http_client_interface.h"
77#include " ../internal/logger.h"
8+ #include " ../internal/url_utils.h"
89
910#include < nlohmann/json.hpp>
1011
@@ -51,7 +52,7 @@ std::vector<CatalogInfo> UnityCatalog::list_catalogs() {
5152CatalogInfo UnityCatalog::get_catalog (const std::string& catalog_name) {
5253 internal::get_logger ()->info (" Getting catalog details for catalog=" + catalog_name);
5354
54- auto response = pimpl_->http_client_ ->get (" /unity-catalog/catalogs/" + catalog_name);
55+ auto response = pimpl_->http_client_ ->get (" /unity-catalog/catalogs/" + internal::url_encode ( catalog_name) );
5556 pimpl_->http_client_ ->check_response (response, " getCatalog" );
5657
5758 internal::get_logger ()->debug (" Catalog details response: " + response.body );
@@ -109,7 +110,7 @@ bool UnityCatalog::delete_catalog(const std::string& catalog_name, bool force) {
109110std::vector<SchemaInfo> UnityCatalog::list_schemas (const std::string& catalog_name) {
110111 internal::get_logger ()->info (" Listing schemas in catalog: " + catalog_name);
111112
112- auto response = pimpl_->http_client_ ->get (" /unity-catalog/schemas?catalog_name=" + catalog_name);
113+ auto response = pimpl_->http_client_ ->get (" /unity-catalog/schemas?catalog_name=" + internal::url_encode ( catalog_name) );
113114 pimpl_->http_client_ ->check_response (response, " listSchemas" );
114115
115116 internal::get_logger ()->debug (" Schemas list response: " + response.body );
@@ -119,7 +120,7 @@ std::vector<SchemaInfo> UnityCatalog::list_schemas(const std::string& catalog_na
119120SchemaInfo UnityCatalog::get_schema (const std::string& full_name) {
120121 internal::get_logger ()->info (" Getting schema details for: " + full_name);
121122
122- auto response = pimpl_->http_client_ ->get (" /unity-catalog/schemas/" + full_name);
123+ auto response = pimpl_->http_client_ ->get (" /unity-catalog/schemas/" + internal::url_encode ( full_name) );
123124 pimpl_->http_client_ ->check_response (response, " getSchema" );
124125
125126 internal::get_logger ()->debug (" Schema details response: " + response.body );
@@ -169,8 +170,9 @@ bool UnityCatalog::delete_schema(const std::string& full_name) {
169170std::vector<TableInfo> UnityCatalog::list_tables (const std::string& catalog_name, const std::string& schema_name) {
170171 internal::get_logger ()->info (" Listing tables in " + catalog_name + " ." + schema_name);
171172
172- // Create Endpoint with Catalog and Schema name
173- std::string endpoint = " /unity-catalog/tables?catalog_name=" + catalog_name + " &schema_name=" + schema_name;
173+ // Create Endpoint with Catalog and Schema name (URL-encoded)
174+ std::string endpoint = " /unity-catalog/tables?catalog_name=" + internal::url_encode (catalog_name) +
175+ " &schema_name=" + internal::url_encode (schema_name);
174176 auto response = pimpl_->http_client_ ->get (endpoint);
175177 pimpl_->http_client_ ->check_response (response, " listTables" );
176178
@@ -181,7 +183,7 @@ std::vector<TableInfo> UnityCatalog::list_tables(const std::string& catalog_name
181183TableInfo UnityCatalog::get_table (const std::string& full_name) {
182184 internal::get_logger ()->info (" Getting table details for: " + full_name);
183185
184- auto response = pimpl_->http_client_ ->get (" /unity-catalog/tables/" + full_name);
186+ auto response = pimpl_->http_client_ ->get (" /unity-catalog/tables/" + internal::url_encode ( full_name) );
185187 pimpl_->http_client_ ->check_response (response, " getTable" );
186188
187189 internal::get_logger ()->debug (" Table details response: " + response.body );
0 commit comments