@@ -161,29 +161,35 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
161161 paths, ResourcePaths::Make (std::string (TrimTrailingSlash (final_uri)),
162162 final_config.Get (RestCatalogProperties::kPrefix )));
163163
164+ // Get snapshot loading mode
165+ ICEBERG_ASSIGN_OR_RAISE (auto snapshot_mode, final_config.SnapshotLoadingMode ());
166+
164167 auto client = std::make_unique<HttpClient>(final_config.ExtractHeaders ());
165168 ICEBERG_ASSIGN_OR_RAISE (auto catalog_session,
166169 auth_manager->CatalogSession (*client, final_config.configs ()));
167170
168- return std::shared_ptr<RestCatalog>(new RestCatalog (
169- std::move (final_config), std::move (file_io), std::move (client), std::move (paths),
170- std::move (endpoints), std::move (auth_manager), std::move (catalog_session)));
171+ return std::shared_ptr<RestCatalog>(
172+ new RestCatalog (std::move (final_config), std::move (file_io), std::move (client),
173+ std::move (paths), std::move (endpoints), std::move (auth_manager),
174+ std::move (catalog_session), snapshot_mode));
171175}
172176
173177RestCatalog::RestCatalog (RestCatalogProperties config, std::shared_ptr<FileIO> file_io,
174178 std::unique_ptr<HttpClient> client,
175179 std::unique_ptr<ResourcePaths> paths,
176180 std::unordered_set<Endpoint> endpoints,
177181 std::unique_ptr<auth::AuthManager> auth_manager,
178- std::shared_ptr<auth::AuthSession> catalog_session)
182+ std::shared_ptr<auth::AuthSession> catalog_session,
183+ SnapshotMode snapshot_mode)
179184 : config_(std::move(config)),
180185 file_io_ (std::move(file_io)),
181186 client_(std::move(client)),
182187 paths_(std::move(paths)),
183188 name_(config_.Get(RestCatalogProperties::kName )),
184189 supported_endpoints_(std::move(endpoints)),
185190 auth_manager_(std::move(auth_manager)),
186- catalog_session_(std::move(catalog_session)) {
191+ catalog_session_(std::move(catalog_session)),
192+ snapshot_mode_(snapshot_mode) {
187193 ICEBERG_DCHECK (catalog_session_ != nullptr , " catalog_session must not be null" );
188194}
189195
@@ -442,9 +448,17 @@ Result<std::string> RestCatalog::LoadTableInternal(
442448 const TableIdentifier& identifier) const {
443449 ICEBERG_ENDPOINT_CHECK (supported_endpoints_, Endpoint::LoadTable ());
444450 ICEBERG_ASSIGN_OR_RAISE (auto path, paths_->Table (identifier));
451+
452+ std::unordered_map<std::string, std::string> params;
453+ if (snapshot_mode_ == SnapshotMode::kRefs ) {
454+ params[" snapshots" ] = " refs" ;
455+ } else {
456+ params[" snapshots" ] = " all" ;
457+ }
458+
445459 ICEBERG_ASSIGN_OR_RAISE (
446460 const auto response,
447- client_->Get (path, /* params= */ {} , /* headers=*/ {}, *TableErrorHandler::Instance (),
461+ client_->Get (path, params, /* headers=*/ {}, *TableErrorHandler::Instance (),
448462 *catalog_session_));
449463 return response.body ();
450464}
@@ -453,7 +467,6 @@ Result<std::shared_ptr<Table>> RestCatalog::LoadTable(const TableIdentifier& ide
453467 ICEBERG_ASSIGN_OR_RAISE (const auto body, LoadTableInternal (identifier));
454468 ICEBERG_ASSIGN_OR_RAISE (auto json, FromJsonString (body));
455469 ICEBERG_ASSIGN_OR_RAISE (auto load_result, LoadTableResultFromJson (json));
456-
457470 return Table::Make (identifier, std::move (load_result.metadata ),
458471 std::move (load_result.metadata_location ), file_io_,
459472 shared_from_this ());
0 commit comments