@@ -364,7 +364,35 @@ TableMetadataBuilder& TableMetadataBuilder::AssignUUID(std::string_view uuid) {
364364
365365TableMetadataBuilder& TableMetadataBuilder::UpgradeFormatVersion (
366366 int8_t new_format_version) {
367- throw IcebergError (std::format (" {} not implemented" , __FUNCTION__));
367+ // Check that the new format version is supported
368+ if (new_format_version > TableMetadata::kSupportedTableFormatVersion ) {
369+ return AddError (
370+ ErrorKind::kInvalidArgument ,
371+ std::format (
372+ " Cannot upgrade table to unsupported format version: v{} (supported: v{})" ,
373+ new_format_version, TableMetadata::kSupportedTableFormatVersion ));
374+ }
375+
376+ // Check that we're not downgrading
377+ if (new_format_version < impl_->metadata .format_version ) {
378+ return AddError (ErrorKind::kInvalidArgument ,
379+ std::format (" Cannot downgrade v{} table to v{}" ,
380+ impl_->metadata .format_version , new_format_version));
381+ }
382+
383+ // No-op if the version is the same
384+ if (new_format_version == impl_->metadata .format_version ) {
385+ return *this ;
386+ }
387+
388+ // Update the format version
389+ impl_->metadata .format_version = new_format_version;
390+
391+ // Record the change
392+ impl_->changes .push_back (
393+ std::make_unique<table::UpgradeFormatVersion>(new_format_version));
394+
395+ return *this ;
368396}
369397
370398TableMetadataBuilder& TableMetadataBuilder::SetCurrentSchema (
@@ -472,12 +500,38 @@ TableMetadataBuilder& TableMetadataBuilder::RemovePartitionStatistics(
472500
473501TableMetadataBuilder& TableMetadataBuilder::SetProperties (
474502 const std::unordered_map<std::string, std::string>& updated) {
475- throw IcebergError (std::format (" {} not implemented" , __FUNCTION__));
503+ // If updated is empty, return early (no-op)
504+ if (updated.empty ()) {
505+ return *this ;
506+ }
507+
508+ // Add all updated properties to the metadata properties
509+ for (const auto & [key, value] : updated) {
510+ impl_->metadata .properties [key] = value;
511+ }
512+
513+ // Record the change
514+ impl_->changes .push_back (std::make_unique<table::SetProperties>(updated));
515+
516+ return *this ;
476517}
477518
478519TableMetadataBuilder& TableMetadataBuilder::RemoveProperties (
479520 const std::vector<std::string>& removed) {
480- throw IcebergError (std::format (" {} not implemented" , __FUNCTION__));
521+ // If removed is empty, return early (no-op)
522+ if (removed.empty ()) {
523+ return *this ;
524+ }
525+
526+ // Remove each property from the metadata properties
527+ for (const auto & key : removed) {
528+ impl_->metadata .properties .erase (key);
529+ }
530+
531+ // Record the change
532+ impl_->changes .push_back (std::make_unique<table::RemoveProperties>(removed));
533+
534+ return *this ;
481535}
482536
483537TableMetadataBuilder& TableMetadataBuilder::SetLocation (std::string_view location) {
0 commit comments