Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/iceberg/test/update_sort_order_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ 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);
}
};

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) {
Expand Down
4 changes: 2 additions & 2 deletions src/iceberg/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}",
Expand Down
4 changes: 2 additions & 2 deletions src/iceberg/update/update_sort_order.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
6 changes: 1 addition & 5 deletions src/iceberg/update/update_sort_order.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Loading