@@ -258,30 +258,53 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
258258 const DB::ContextPtr & context)
259259{
260260 if (isRelativePath (path))
261+ {
262+ if (base_storage)
263+ std::cerr << " \n Relative path: " << base_storage->getName () << " , " << base_storage->getObjectsNamespace () << " \n " ;
264+ else
265+ std::cerr << " \n Relative, returning base, which is: NULL\n " ;
261266 return {base_storage, path}; // Relative path definitely goes to base storage
267+ }
262268
263269 SchemeAuthorityKey base{table_location};
264270 SchemeAuthorityKey target{path};
265271
266272 if (target.scheme .empty ())
273+ {
274+ if (base_storage)
275+ std::cerr << " \n No scheme, returning base, which is: " << base_storage->getName () << " , " << base_storage->getObjectsNamespace () << " \n " ;
276+ else
277+
278+ std::cerr << " \n No scheme, returning base, which is: NULL\n " ;
267279 return {base_storage, target.key };
280+ }
268281
269282 const std::string base_norm = normalizeSchema (base.scheme );
270283 const std::string target_norm = normalizeSchema (target.scheme );
271284
272285 // Reuse base storage if scheme and authority (bucket) matches
273- if (!base.scheme .empty ()
274- && base_norm == target_norm
275- && base.authority == target.authority )
286+ if (base_norm == target_norm && base.authority == target.authority )
276287 {
288+ if (base_storage)
289+ std::cerr << " \n Same location, returning base, which is: " << base_storage->getName () << " , " << base_storage->getObjectsNamespace () << " \n " ;
290+ else
291+ std::cerr << " \n Same location, returning base, which is: NULL\n " ;
277292 return {base_storage, target.key };
278293 }
279294
280295 const std::string cache_key = endpoint_cache_key (target_norm, target.authority );
281296 if (auto it = secondary_storages.find (cache_key); it != secondary_storages.end ())
297+ {
298+ if (it->second )
299+ std::cerr << " \n found in cache: " << it->second ->getName () << " , " << it->second ->getObjectsNamespace () << " \n " ;
300+ else
301+ std::cerr << " \n found in cache: NULL\n " ;
282302 return {it->second , target.key };
303+ }
304+
305+ // / TODO: maybe do not invent new configuration. Use old one and clean up later
306+ Poco::AutoPtr<Poco::Util::MapConfiguration> cfg (new Poco::Util::MapConfiguration);
283307
284- Poco::AutoPtr<Poco::Util::MapConfiguration> cfg;
285308 const std::string type_for_factory = factoryTypeForScheme (target_norm);
286309 if (type_for_factory.empty ())
287310 throw DB::Exception (DB::ErrorCodes::BAD_ARGUMENTS, " Unsupported storage scheme '{}' in path '{}'" , target_norm, path);
@@ -292,12 +315,12 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
292315
293316 if (target_norm == " s3" || target_norm == " abfs" )
294317 {
295- cfg->setString (config_prefix + " .endpoint" , target.authority );
318+ cfg->setString (config_prefix + " .endpoint" , target_norm + " :// " + target.authority );
296319 }
297320 else if (target_norm == " hdfs" )
298321 {
299322 // HDFS endpoint must end with '/'
300- auto endpoint = target.authority ;
323+ auto endpoint = target_norm + " :// " + target.authority ;
301324 if (!endpoint.empty () && endpoint.back () != ' /' )
302325 endpoint.push_back (' /' );
303326 cfg->setString (config_prefix + " .endpoint" , endpoint);
@@ -310,6 +333,10 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
310333 DB::ObjectStoragePtr storage = factory.create (cache_key, *cfg, config_prefix, context, /* skip_access_check*/ true );
311334
312335 secondary_storages.emplace (cache_key, storage);
336+ if (storage)
337+ std::cerr << " \n created new storage: " << storage->getName () << " , " << storage->getObjectsNamespace () << " \n " ;
338+ else
339+ std::cerr << " \n created new storage: it is NULL\n " ;
313340 return {storage, target.key };
314341}
315342
0 commit comments