WZhuo commented on code in PR #437:
URL: https://github.com/apache/iceberg-cpp/pull/437#discussion_r2646593501


##########
src/iceberg/table_metadata.cc:
##########
@@ -709,16 +919,24 @@ TableMetadataBuilder& 
TableMetadataBuilder::UpgradeFormatVersion(
 }
 
 TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema(
-    std::shared_ptr<Schema> schema, int32_t new_last_column_id) {
-  throw IcebergError(std::format("{} not implemented", __FUNCTION__));
+    std::shared_ptr<Schema> const& schema, int32_t new_last_column_id) {
+  ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto schema_id,
+                                   impl_->AddSchema(*schema, 
new_last_column_id));
+  return SetCurrentSchema(schema_id);
 }
 
 TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema(int32_t 
schema_id) {
-  throw IcebergError(std::format("{} not implemented", __FUNCTION__));
+  ICEBERG_BUILDER_RETURN_IF_ERROR(impl_->SetCurrentSchema(schema_id));
+  return *this;
 }
 
-TableMetadataBuilder& TableMetadataBuilder::AddSchema(std::shared_ptr<Schema> 
schema) {
-  throw IcebergError(std::format("{} not implemented", __FUNCTION__));
+TableMetadataBuilder& TableMetadataBuilder::AddSchema(
+    std::shared_ptr<Schema> const& schema) {
+  ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto highest_field_id, 
schema->HighestFieldId());
+  auto new_last_column_id = std::max(impl_->metadata().last_column_id, 
highest_field_id);
+  ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto schema_id,
+                                   impl_->AddSchema(*schema, 
new_last_column_id));

Review Comment:
   ```suggestion
     ICEBERG_BUILDER_RETURN_IF_ERROR(impl_->AddSchema(*schema, 
new_last_column_id));
   ```
   schema_id is not used



-- 
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