This is an automated email from the ASF dual-hosted git repository.

gangwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new a6cdea4d refactor: simplify UpdateSortOrder::Apply() return type (#436)
a6cdea4d is described below

commit a6cdea4d96bb56f346c94075bbd7b09d5f3956dc
Author: Feiyang Li <[email protected]>
AuthorDate: Thu Dec 25 11:25:49 2025 +0800

    refactor: simplify UpdateSortOrder::Apply() return type (#436)
---
 src/iceberg/test/update_sort_order_test.cc | 6 +++---
 src/iceberg/transaction.cc                 | 4 ++--
 src/iceberg/update/update_sort_order.cc    | 4 ++--
 src/iceberg/update/update_sort_order.h     | 6 +-----
 4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/iceberg/test/update_sort_order_test.cc 
b/src/iceberg/test/update_sort_order_test.cc
index e5f5fc0e..4d83d381 100644
--- a/src/iceberg/test/update_sort_order_test.cc
+++ b/src/iceberg/test/update_sort_order_test.cc
@@ -44,8 +44,8 @@ class UpdateSortOrderTest : public UpdateTestBase {
     ICEBERG_UNWRAP_OR_FAIL(auto result, update->Apply());
     ICEBERG_UNWRAP_OR_FAIL(
         auto expected_sort_order,
-        SortOrder::Make(result.sort_order->order_id(), 
std::move(expected_fields)));
-    EXPECT_EQ(*result.sort_order, *expected_sort_order);
+        SortOrder::Make(result->order_id(), std::move(expected_fields)));
+    EXPECT_EQ(*result, *expected_sort_order);
   }
 };
 
@@ -53,7 +53,7 @@ TEST_F(UpdateSortOrderTest, EmptySortOrder) {
   ICEBERG_UNWRAP_OR_FAIL(auto update, table_->NewUpdateSortOrder());
   ICEBERG_UNWRAP_OR_FAIL(auto result, update->Apply());
   // Should succeed with an unsorted order
-  EXPECT_TRUE(result.sort_order->fields().empty());
+  EXPECT_TRUE(result->fields().empty());
 }
 
 TEST_F(UpdateSortOrderTest, AddSingleSortFieldAscending) {
diff --git a/src/iceberg/transaction.cc b/src/iceberg/transaction.cc
index 49416cdc..8bc2a539 100644
--- a/src/iceberg/transaction.cc
+++ b/src/iceberg/transaction.cc
@@ -82,8 +82,8 @@ Status Transaction::Apply(PendingUpdate& update) {
     } break;
     case PendingUpdate::Kind::kUpdateSortOrder: {
       auto& update_sort_order = 
internal::checked_cast<UpdateSortOrder&>(update);
-      ICEBERG_ASSIGN_OR_RAISE(auto result, update_sort_order.Apply());
-      metadata_builder_->SetDefaultSortOrder(result.sort_order);
+      ICEBERG_ASSIGN_OR_RAISE(auto sort_order, update_sort_order.Apply());
+      metadata_builder_->SetDefaultSortOrder(std::move(sort_order));
     } break;
     default:
       return NotSupported("Unsupported pending update: {}",
diff --git a/src/iceberg/update/update_sort_order.cc 
b/src/iceberg/update/update_sort_order.cc
index c31d2ba7..e3e651d5 100644
--- a/src/iceberg/update/update_sort_order.cc
+++ b/src/iceberg/update/update_sort_order.cc
@@ -87,7 +87,7 @@ UpdateSortOrder& UpdateSortOrder::CaseSensitive(bool 
case_sensitive) {
   return *this;
 }
 
-Result<UpdateSortOrder::ApplyResult> UpdateSortOrder::Apply() {
+Result<std::shared_ptr<SortOrder>> UpdateSortOrder::Apply() {
   ICEBERG_RETURN_UNEXPECTED(CheckErrors());
 
   // If no sort fields are specified, return an unsorted order (ID = 0).
@@ -102,7 +102,7 @@ Result<UpdateSortOrder::ApplyResult> 
UpdateSortOrder::Apply() {
     ICEBERG_ASSIGN_OR_RAISE(auto schema, transaction_->current().Schema());
     ICEBERG_RETURN_UNEXPECTED(order->Validate(*schema));
   }
-  return ApplyResult{std::move(order)};
+  return order;
 }
 
 }  // namespace iceberg
diff --git a/src/iceberg/update/update_sort_order.h 
b/src/iceberg/update/update_sort_order.h
index 7983513b..364a70f6 100644
--- a/src/iceberg/update/update_sort_order.h
+++ b/src/iceberg/update/update_sort_order.h
@@ -41,10 +41,6 @@ class ICEBERG_EXPORT UpdateSortOrder : public PendingUpdate {
 
   ~UpdateSortOrder() override;
 
-  struct ApplyResult {
-    std::shared_ptr<SortOrder> sort_order;
-  };
-
   /// \brief Add a sort field to the sort order.
   ///
   /// \param term A transform term referencing the field
@@ -72,7 +68,7 @@ class ICEBERG_EXPORT UpdateSortOrder : public PendingUpdate {
   Kind kind() const final { return Kind::kUpdateSortOrder; }
 
   /// \brief Apply the pending changes and return the new SortOrder.
-  Result<ApplyResult> Apply();
+  Result<std::shared_ptr<SortOrder>> Apply();
 
  private:
   explicit UpdateSortOrder(std::shared_ptr<Transaction> transaction);

Reply via email to