From 2abe284859263d7285903196884bcf1de6debcfd Mon Sep 17 00:00:00 2001 From: Daniil Rubin Date: Tue, 30 Aug 2022 17:38:02 +0000 Subject: [PATCH] Fix engine bug --- src/Storages/StorageHudi.cpp | 11 ++++++----- src/Storages/StorageHudi.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Storages/StorageHudi.cpp b/src/Storages/StorageHudi.cpp index efba2d3f85f..b4eba258d0e 100644 --- a/src/Storages/StorageHudi.cpp +++ b/src/Storages/StorageHudi.cpp @@ -33,6 +33,7 @@ StorageHudi::StorageHudi( : IStorage(table_id_) , base_configuration({uri_, access_key_, secret_access_key_, {}, {}, {}}) , log(&Poco::Logger::get("StorageHudi (" + table_id_.table_name + ")")) + , table_path(uri_.key) { StorageInMemoryMetadata storage_metadata; updateS3Configuration(context_, base_configuration); @@ -42,7 +43,7 @@ StorageHudi::StorageHudi( auto new_uri = base_configuration.uri.uri.toString() + generateQueryFromKeys(std::move(keys)); LOG_DEBUG(log, "New uri: {}", new_uri); - + LOG_DEBUG(log, "Table path: {}", table_path); auto s3_uri = S3::URI(Poco::URI(new_uri)); if (columns_.empty()) @@ -143,9 +144,9 @@ std::vector StorageHudi::getKeysFromS3() bool is_finished{false}; const auto bucket{base_configuration.uri.bucket}; - const std::string key = ""; request.SetBucket(bucket); + request.SetPrefix(table_path); while (!is_finished) { @@ -155,16 +156,16 @@ std::vector StorageHudi::getKeysFromS3() ErrorCodes::S3_ERROR, "Could not list objects in bucket {} with key {}, S3 exception: {}, message: {}", quoteString(bucket), - quoteString(key), + quoteString(table_path), backQuote(outcome.GetError().GetExceptionName()), quoteString(outcome.GetError().GetMessage())); const auto & result_batch = outcome.GetResult().GetContents(); for (const auto & obj : result_batch) { - const auto & filename = obj.GetKey(); + const auto & filename = obj.GetKey().substr(table_path.size()); // object name without tablepath prefix keys.push_back(filename); - //LOG_DEBUG(log, "Found file: {}", filename); + LOG_DEBUG(log, "Found file: {}", filename); } request.SetContinuationToken(outcome.GetResult().GetNextContinuationToken()); diff --git a/src/Storages/StorageHudi.h b/src/Storages/StorageHudi.h index dd5cc18495e..47dff1c2a7b 100644 --- a/src/Storages/StorageHudi.h +++ b/src/Storages/StorageHudi.h @@ -53,6 +53,7 @@ private: StorageS3::S3Configuration base_configuration; std::shared_ptr s3engine; Poco::Logger * log; + String table_path; }; }