@@ -49,10 +49,20 @@ UpdatePartitionSpec::UpdatePartitionSpec(TableIdentifier identifier,
4949 format_version_ = base_metadata_->format_version ;
5050
5151 // Get the current/default partition spec
52- ICEBERG_ASSIGN_OR_THROW (spec_, base_metadata_->PartitionSpec ());
52+ auto spec_result = base_metadata_->PartitionSpec ();
53+ if (!spec_result.has_value ()) {
54+ AddError (spec_result.error ());
55+ return ;
56+ }
57+ spec_ = std::move (spec_result.value ());
5358
5459 // Get the current schema
55- ICEBERG_ASSIGN_OR_THROW (schema_, base_metadata_->Schema ());
60+ auto schema_result = base_metadata_->Schema ();
61+ if (!schema_result.has_value ()) {
62+ AddError (schema_result.error ());
63+ return ;
64+ }
65+ schema_ = std::move (schema_result.value ());
5666
5767 last_assigned_partition_id_ = spec_->last_assigned_field_id ();
5868 name_to_field_ = IndexSpecByName (*spec_);
@@ -420,10 +430,9 @@ Status UpdatePartitionSpec::Apply() {
420430 last_assigned_id = PartitionSpec::kLegacyPartitionDataIdStart - 1 ;
421431 }
422432
423- // TODO(anyone): Use the Make method with schema_.
424433 ICEBERG_ASSIGN_OR_RAISE (
425- auto spec_result,
426- PartitionSpec::Make (new_spec_id, std::move (new_fields), last_assigned_id));
434+ auto spec_result, PartitionSpec::Make (*schema_, new_spec_id, std::move (new_fields),
435+ last_assigned_id));
427436 applied_spec_ = std::shared_ptr<PartitionSpec>(spec_result.release ());
428437 return {};
429438}
0 commit comments