wgtmac commented on code in PR #412:
URL: https://github.com/apache/iceberg-cpp/pull/412#discussion_r2623554576


##########
src/iceberg/type_fwd.h:
##########
@@ -163,6 +163,7 @@ class PendingUpdate;
 template <typename T>
 class PendingUpdateTyped;

Review Comment:
   ```suggestion
   ```
   
   Please help remove this.



##########
src/iceberg/update/replace_sort_order.cc:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/update/replace_sort_order.h"
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "iceberg/catalog.h"
+#include "iceberg/expression/term.h"
+#include "iceberg/result.h"
+#include "iceberg/sort_field.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/transform.h"
+#include "iceberg/util/checked_cast.h"
+#include "iceberg/util/error_collector.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+ReplaceSortOrder::ReplaceSortOrder(TableIdentifier identifier,
+                                   std::shared_ptr<Catalog> catalog,
+                                   std::shared_ptr<TableMetadata> base)
+    : identifier_(std::move(identifier)),
+      catalog_(std::move(catalog)),
+      base_metadata_(std::move(base)) {}
+
+ReplaceSortOrder& ReplaceSortOrder::Asc(std::shared_ptr<Term> term,
+                                        NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Term cannot be null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be a transform 
term");
+  }
+  if (!term->is_unbound()) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be unbound");
+  }
+  // use checked-cast to get UnboundTransform
+  auto unbound_transform = 
internal::checked_pointer_cast<UnboundTransform>(term);
+
+  BUILDER_ASSIGN_OR_RETURN(auto schema, base_metadata_->Schema());
+  BUILDER_ASSIGN_OR_RETURN(auto bound_term,
+                           unbound_transform->Bind(*schema, case_sensitive_));
+  return AddSortField(bound_term->reference(), unbound_transform->transform(),
+                      SortDirection::kAscending, null_order);
+}
+
+ReplaceSortOrder& ReplaceSortOrder::Desc(std::shared_ptr<Term> term,

Review Comment:
   This looks so similar to the above `Asc` call. Can we just make 
`SortDirection` as a parameter to combine these two functions?



##########
src/iceberg/update/replace_sort_order.cc:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/update/replace_sort_order.h"
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "iceberg/catalog.h"
+#include "iceberg/expression/term.h"
+#include "iceberg/result.h"
+#include "iceberg/sort_field.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/transform.h"
+#include "iceberg/util/checked_cast.h"
+#include "iceberg/util/error_collector.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+ReplaceSortOrder::ReplaceSortOrder(TableIdentifier identifier,
+                                   std::shared_ptr<Catalog> catalog,
+                                   std::shared_ptr<TableMetadata> base)
+    : identifier_(std::move(identifier)),
+      catalog_(std::move(catalog)),
+      base_metadata_(std::move(base)) {}
+
+ReplaceSortOrder& ReplaceSortOrder::Asc(std::shared_ptr<Term> term,
+                                        NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Term cannot be null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {

Review Comment:
   ```suggestion
     if (term->kind() != Term::Kind::kTransform) {
   ```



##########
src/iceberg/update/replace_sort_order.cc:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/update/replace_sort_order.h"
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "iceberg/catalog.h"
+#include "iceberg/expression/term.h"
+#include "iceberg/result.h"
+#include "iceberg/sort_field.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/transform.h"
+#include "iceberg/util/checked_cast.h"
+#include "iceberg/util/error_collector.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+ReplaceSortOrder::ReplaceSortOrder(TableIdentifier identifier,
+                                   std::shared_ptr<Catalog> catalog,
+                                   std::shared_ptr<TableMetadata> base)
+    : identifier_(std::move(identifier)),
+      catalog_(std::move(catalog)),
+      base_metadata_(std::move(base)) {}
+
+ReplaceSortOrder& ReplaceSortOrder::Asc(std::shared_ptr<Term> term,
+                                        NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Term cannot be null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be a transform 
term");
+  }
+  if (!term->is_unbound()) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be unbound");
+  }
+  // use checked-cast to get UnboundTransform
+  auto unbound_transform = 
internal::checked_pointer_cast<UnboundTransform>(term);
+
+  BUILDER_ASSIGN_OR_RETURN(auto schema, base_metadata_->Schema());
+  BUILDER_ASSIGN_OR_RETURN(auto bound_term,
+                           unbound_transform->Bind(*schema, case_sensitive_));
+  return AddSortField(bound_term->reference(), unbound_transform->transform(),
+                      SortDirection::kAscending, null_order);
+}
+
+ReplaceSortOrder& ReplaceSortOrder::Desc(std::shared_ptr<Term> term,
+                                         NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Transform term cannot be 
null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be a transform 
term");
+  }
+  if (!term->is_unbound()) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be unbound");
+  }
+  // use checked-cast to get UnboundTransform
+  auto unbound_transform = 
internal::checked_pointer_cast<UnboundTransform>(term);
+  BUILDER_ASSIGN_OR_RETURN(auto schema, base_metadata_->Schema());
+  BUILDER_ASSIGN_OR_RETURN(auto bound_term,
+                           unbound_transform->Bind(*schema, case_sensitive_));
+  return AddSortField(bound_term->reference(), unbound_transform->transform(),
+                      SortDirection::kDescending, null_order);
+}
+
+ReplaceSortOrder& ReplaceSortOrder::CaseSensitive(bool case_sensitive) {
+  case_sensitive_ = case_sensitive;
+  return *this;
+}
+
+ReplaceSortOrder& 
ReplaceSortOrder::AddSortField(std::shared_ptr<BoundReference> ref,
+                                                 std::shared_ptr<Transform> 
transform,
+                                                 SortDirection direction,
+                                                 NullOrder null_order) {
+  int32_t source_id = ref->field_id();
+  const auto& field = ref->field();
+
+  // Validate that the transform can be applied to the field type  、
+  if (!transform->CanTransform(*field.type())) {

Review Comment:
   We can skip this check because you have called `order->Validate` in the 
`Apply()`. They are doing the same thing.



##########
src/iceberg/update/replace_sort_order.cc:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/update/replace_sort_order.h"
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "iceberg/catalog.h"
+#include "iceberg/expression/term.h"
+#include "iceberg/result.h"
+#include "iceberg/sort_field.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/transform.h"
+#include "iceberg/util/checked_cast.h"
+#include "iceberg/util/error_collector.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+ReplaceSortOrder::ReplaceSortOrder(TableIdentifier identifier,
+                                   std::shared_ptr<Catalog> catalog,
+                                   std::shared_ptr<TableMetadata> base)
+    : identifier_(std::move(identifier)),
+      catalog_(std::move(catalog)),
+      base_metadata_(std::move(base)) {}
+
+ReplaceSortOrder& ReplaceSortOrder::Asc(std::shared_ptr<Term> term,
+                                        NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Term cannot be null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be a transform 
term");
+  }
+  if (!term->is_unbound()) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be unbound");
+  }
+  // use checked-cast to get UnboundTransform
+  auto unbound_transform = 
internal::checked_pointer_cast<UnboundTransform>(term);
+
+  BUILDER_ASSIGN_OR_RETURN(auto schema, base_metadata_->Schema());
+  BUILDER_ASSIGN_OR_RETURN(auto bound_term,
+                           unbound_transform->Bind(*schema, case_sensitive_));
+  return AddSortField(bound_term->reference(), unbound_transform->transform(),
+                      SortDirection::kAscending, null_order);
+}
+
+ReplaceSortOrder& ReplaceSortOrder::Desc(std::shared_ptr<Term> term,
+                                         NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Transform term cannot be 
null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be a transform 
term");
+  }
+  if (!term->is_unbound()) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be unbound");
+  }
+  // use checked-cast to get UnboundTransform
+  auto unbound_transform = 
internal::checked_pointer_cast<UnboundTransform>(term);
+  BUILDER_ASSIGN_OR_RETURN(auto schema, base_metadata_->Schema());
+  BUILDER_ASSIGN_OR_RETURN(auto bound_term,
+                           unbound_transform->Bind(*schema, case_sensitive_));
+  return AddSortField(bound_term->reference(), unbound_transform->transform(),
+                      SortDirection::kDescending, null_order);
+}
+
+ReplaceSortOrder& ReplaceSortOrder::CaseSensitive(bool case_sensitive) {
+  case_sensitive_ = case_sensitive;
+  return *this;
+}
+
+ReplaceSortOrder& 
ReplaceSortOrder::AddSortField(std::shared_ptr<BoundReference> ref,
+                                                 std::shared_ptr<Transform> 
transform,
+                                                 SortDirection direction,
+                                                 NullOrder null_order) {
+  int32_t source_id = ref->field_id();
+  const auto& field = ref->field();
+
+  // Validate that the transform can be applied to the field type  、
+  if (!transform->CanTransform(*field.type())) {
+    return AddError(
+        ErrorKind::kInvalidArgument,
+        std::format("Invalid transform {} for field '{}' with type {}",
+                    transform->ToString(), field.name(), 
field.type()->ToString()));
+  }
+
+  sort_fields_.emplace_back(source_id, std::move(transform), direction, 
null_order);
+  return *this;
+}
+
+Status ReplaceSortOrder::Apply() {
+  ICEBERG_RETURN_UNEXPECTED(CheckErrors());
+  // Note: We use kInitialSortOrderId (1) here like the Java implementation.
+  // The actual sort order ID will be assigned by TableMetadataBuilder when
+  // the AddSortOrder update is applied.
+  ICEBERG_ASSIGN_OR_RAISE(auto order,
+                          SortOrder::Make(SortOrder::kInitialSortOrderId, 
sort_fields_));
+  
ICEBERG_RETURN_UNEXPECTED(order->Validate(*base_metadata_->Schema().value()));

Review Comment:
   `base_metadata_->Schema()` has been called several times in this class but 
it is not cheap. Please consider caching and reusing the schema.



##########
src/iceberg/update/replace_sort_order.cc:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/update/replace_sort_order.h"
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "iceberg/catalog.h"
+#include "iceberg/expression/term.h"
+#include "iceberg/result.h"
+#include "iceberg/sort_field.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/transform.h"
+#include "iceberg/util/checked_cast.h"
+#include "iceberg/util/error_collector.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+ReplaceSortOrder::ReplaceSortOrder(TableIdentifier identifier,
+                                   std::shared_ptr<Catalog> catalog,
+                                   std::shared_ptr<TableMetadata> base)
+    : identifier_(std::move(identifier)),
+      catalog_(std::move(catalog)),
+      base_metadata_(std::move(base)) {}
+
+ReplaceSortOrder& ReplaceSortOrder::Asc(std::shared_ptr<Term> term,
+                                        NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Term cannot be null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be a transform 
term");
+  }
+  if (!term->is_unbound()) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be unbound");
+  }
+  // use checked-cast to get UnboundTransform
+  auto unbound_transform = 
internal::checked_pointer_cast<UnboundTransform>(term);
+
+  BUILDER_ASSIGN_OR_RETURN(auto schema, base_metadata_->Schema());
+  BUILDER_ASSIGN_OR_RETURN(auto bound_term,
+                           unbound_transform->Bind(*schema, case_sensitive_));
+  return AddSortField(bound_term->reference(), unbound_transform->transform(),
+                      SortDirection::kAscending, null_order);
+}
+
+ReplaceSortOrder& ReplaceSortOrder::Desc(std::shared_ptr<Term> term,
+                                         NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Transform term cannot be 
null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be a transform 
term");
+  }
+  if (!term->is_unbound()) {
+    return AddError(ErrorKind::kInvalidArgument, "Term must be unbound");
+  }
+  // use checked-cast to get UnboundTransform
+  auto unbound_transform = 
internal::checked_pointer_cast<UnboundTransform>(term);
+  BUILDER_ASSIGN_OR_RETURN(auto schema, base_metadata_->Schema());
+  BUILDER_ASSIGN_OR_RETURN(auto bound_term,
+                           unbound_transform->Bind(*schema, case_sensitive_));
+  return AddSortField(bound_term->reference(), unbound_transform->transform(),
+                      SortDirection::kDescending, null_order);
+}
+
+ReplaceSortOrder& ReplaceSortOrder::CaseSensitive(bool case_sensitive) {
+  case_sensitive_ = case_sensitive;
+  return *this;
+}
+
+ReplaceSortOrder& 
ReplaceSortOrder::AddSortField(std::shared_ptr<BoundReference> ref,
+                                                 std::shared_ptr<Transform> 
transform,
+                                                 SortDirection direction,
+                                                 NullOrder null_order) {
+  int32_t source_id = ref->field_id();
+  const auto& field = ref->field();
+
+  // Validate that the transform can be applied to the field type  、
+  if (!transform->CanTransform(*field.type())) {

Review Comment:
   If you remove this check, we don't need to pass 
`std::shared_ptr<BoundReference> ref` and just need an extra `int32_t 
source_id`.



##########
src/iceberg/update/replace_sort_order.cc:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/update/replace_sort_order.h"
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "iceberg/catalog.h"
+#include "iceberg/expression/term.h"
+#include "iceberg/result.h"
+#include "iceberg/sort_field.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/transform.h"
+#include "iceberg/util/checked_cast.h"
+#include "iceberg/util/error_collector.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+ReplaceSortOrder::ReplaceSortOrder(TableIdentifier identifier,
+                                   std::shared_ptr<Catalog> catalog,
+                                   std::shared_ptr<TableMetadata> base)
+    : identifier_(std::move(identifier)),
+      catalog_(std::move(catalog)),
+      base_metadata_(std::move(base)) {}
+
+ReplaceSortOrder& ReplaceSortOrder::Asc(std::shared_ptr<Term> term,
+                                        NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Term cannot be null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {

Review Comment:
   It is weird to use `BoundTerm` here.



##########
src/iceberg/meson.build:
##########
@@ -196,6 +197,7 @@ install_headers(
         'transform.h',
         'type_fwd.h',
         'type.h',
+        'update/replace_sort_order.h',

Review Comment:
   We need to add `iceberg/update/meson.build` to install update/*.h. Could you 
fix this?



##########
src/iceberg/update/replace_sort_order.cc:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/update/replace_sort_order.h"
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "iceberg/catalog.h"
+#include "iceberg/expression/term.h"
+#include "iceberg/result.h"
+#include "iceberg/sort_field.h"
+#include "iceberg/sort_order.h"
+#include "iceberg/table.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/transform.h"
+#include "iceberg/util/checked_cast.h"
+#include "iceberg/util/error_collector.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+ReplaceSortOrder::ReplaceSortOrder(TableIdentifier identifier,
+                                   std::shared_ptr<Catalog> catalog,
+                                   std::shared_ptr<TableMetadata> base)
+    : identifier_(std::move(identifier)),
+      catalog_(std::move(catalog)),
+      base_metadata_(std::move(base)) {}
+
+ReplaceSortOrder& ReplaceSortOrder::Asc(std::shared_ptr<Term> term,
+                                        NullOrder null_order) {
+  if (!term) {
+    return AddError(ErrorKind::kInvalidArgument, "Term cannot be null");
+  }
+  if (term->kind() != BoundTerm::Kind::kTransform) {

Review Comment:
   BTW, it is totally valid to see `Term::Kind::kReference` here.



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