wgtmac commented on code in PR #485:
URL: https://github.com/apache/iceberg-cpp/pull/485#discussion_r2664277159


##########
src/iceberg/catalog/rest/rest_catalog.cc:
##########
@@ -298,10 +299,19 @@ Result<std::shared_ptr<Table>> RestCatalog::CreateTable(
       client_->Post(path, json_request, /*headers=*/{}, 
*TableErrorHandler::Instance()));
 
   ICEBERG_ASSIGN_OR_RAISE(auto json, FromJsonString(response.body()));
-  ICEBERG_ASSIGN_OR_RAISE(auto load_result, LoadTableResultFromJson(json));
-  return Table::Make(identifier, load_result.metadata,
-                     std::move(load_result.metadata_location), file_io_,
-                     shared_from_this());
+  return LoadTableResultFromJson(json);
+}
+
+Result<std::shared_ptr<Table>> RestCatalog::CreateTable(
+    const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
+    const std::shared_ptr<PartitionSpec>& spec, const 
std::shared_ptr<SortOrder>& order,
+    const std::string& location,
+    const std::unordered_map<std::string, std::string>& properties) {
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto result,
+      CreateTableInternal(identifier, schema, spec, order, location, 
properties, false));

Review Comment:
   ```suggestion
         CreateTableInternal(identifier, schema, spec, order, location, 
properties, /*stage_create=*/false));
   ```



##########
src/iceberg/catalog/rest/rest_catalog.cc:
##########
@@ -335,13 +345,19 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
 }
 
 Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable(
-    [[maybe_unused]] const TableIdentifier& identifier,
-    [[maybe_unused]] const std::shared_ptr<Schema>& schema,
-    [[maybe_unused]] const std::shared_ptr<PartitionSpec>& spec,
-    [[maybe_unused]] const std::shared_ptr<SortOrder>& order,
-    [[maybe_unused]] const std::string& location,
-    [[maybe_unused]] const std::unordered_map<std::string, std::string>& 
properties) {
-  return NotImplemented("Not implemented");
+    const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
+    const std::shared_ptr<PartitionSpec>& spec, const 
std::shared_ptr<SortOrder>& order,
+    const std::string& location,
+    const std::unordered_map<std::string, std::string>& properties) {
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto result,
+      CreateTableInternal(identifier, schema, spec, order, location, 
properties, true));
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto staged_table,
+      StagedTable::Make(identifier, result.metadata, 
std::move(result.metadata_location),

Review Comment:
   ```suggestion
         StagedTable::Make(identifier, std::move(result.metadata), 
std::move(result.metadata_location),
   ```



##########
src/iceberg/catalog/rest/rest_catalog.cc:
##########
@@ -335,13 +345,19 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
 }
 
 Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable(
-    [[maybe_unused]] const TableIdentifier& identifier,
-    [[maybe_unused]] const std::shared_ptr<Schema>& schema,
-    [[maybe_unused]] const std::shared_ptr<PartitionSpec>& spec,
-    [[maybe_unused]] const std::shared_ptr<SortOrder>& order,
-    [[maybe_unused]] const std::string& location,
-    [[maybe_unused]] const std::unordered_map<std::string, std::string>& 
properties) {
-  return NotImplemented("Not implemented");
+    const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
+    const std::shared_ptr<PartitionSpec>& spec, const 
std::shared_ptr<SortOrder>& order,
+    const std::string& location,
+    const std::unordered_map<std::string, std::string>& properties) {
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto result,
+      CreateTableInternal(identifier, schema, spec, order, location, 
properties, true));
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto staged_table,
+      StagedTable::Make(identifier, result.metadata, 
std::move(result.metadata_location),
+                        file_io_, shared_from_this()));
+  return Transaction::Make(staged_table, Transaction::Kind::kCreate,

Review Comment:
   ```suggestion
     return Transaction::Make(std::move(staged_table), 
Transaction::Kind::kCreate,
   ```



##########
src/iceberg/catalog/rest/rest_catalog.cc:
##########
@@ -335,13 +345,19 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
 }
 
 Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable(
-    [[maybe_unused]] const TableIdentifier& identifier,
-    [[maybe_unused]] const std::shared_ptr<Schema>& schema,
-    [[maybe_unused]] const std::shared_ptr<PartitionSpec>& spec,
-    [[maybe_unused]] const std::shared_ptr<SortOrder>& order,
-    [[maybe_unused]] const std::string& location,
-    [[maybe_unused]] const std::unordered_map<std::string, std::string>& 
properties) {
-  return NotImplemented("Not implemented");
+    const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
+    const std::shared_ptr<PartitionSpec>& spec, const 
std::shared_ptr<SortOrder>& order,
+    const std::string& location,
+    const std::unordered_map<std::string, std::string>& properties) {
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto result,
+      CreateTableInternal(identifier, schema, spec, order, location, 
properties, true));

Review Comment:
   ```suggestion
         CreateTableInternal(identifier, schema, spec, order, location, 
properties, /*stage_create=*/true));
   ```



##########
src/iceberg/catalog/rest/rest_catalog.cc:
##########
@@ -298,10 +299,19 @@ Result<std::shared_ptr<Table>> RestCatalog::CreateTable(
       client_->Post(path, json_request, /*headers=*/{}, 
*TableErrorHandler::Instance()));
 
   ICEBERG_ASSIGN_OR_RAISE(auto json, FromJsonString(response.body()));
-  ICEBERG_ASSIGN_OR_RAISE(auto load_result, LoadTableResultFromJson(json));
-  return Table::Make(identifier, load_result.metadata,
-                     std::move(load_result.metadata_location), file_io_,
-                     shared_from_this());
+  return LoadTableResultFromJson(json);
+}
+
+Result<std::shared_ptr<Table>> RestCatalog::CreateTable(
+    const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
+    const std::shared_ptr<PartitionSpec>& spec, const 
std::shared_ptr<SortOrder>& order,
+    const std::string& location,
+    const std::unordered_map<std::string, std::string>& properties) {
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto result,
+      CreateTableInternal(identifier, schema, spec, order, location, 
properties, false));
+  return Table::Make(identifier, result.metadata, 
std::move(result.metadata_location),

Review Comment:
   ```suggestion
     return Table::Make(identifier, std::move(result.metadata), 
std::move(result.metadata_location),
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to