cmcarthur commented on code in PR #1176:
URL: https://github.com/apache/iceberg-rust/pull/1176#discussion_r2031711629


##########
crates/iceberg/src/transaction/add_field.rs:
##########
@@ -0,0 +1,114 @@
+// 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.
+
+//! This module contains an AddFieldsAction for adding fields to a table.
+
+use crate::error::Result;
+use crate::spec::NestedFieldRef;
+use crate::transaction::Transaction;
+use crate::{TableRequirement, TableUpdate};
+
+/// Transaction action for easily adding fields to the table.
+pub struct AddFieldsAction<'a> {
+    tx: Transaction<'a>,
+    fields: Vec<NestedFieldRef>,
+}
+
+/// Transaction action for easily adding fields to the table.
+impl<'a> AddFieldsAction<'a> {
+    /// Creates a new `AddFieldsAction` for the given transaction.
+    pub(crate) fn new(tx: Transaction<'a>, fields: Vec<NestedFieldRef>) -> 
Self {
+        Self { tx, fields }
+    }
+
+    /// Finish building the action and apply it to the transaction.
+    pub fn apply(mut self) -> Result<Transaction<'a>> {
+        let base_schema = self.tx.table.metadata().current_schema();
+        let schema_builder = <crate::spec::Schema as 
Clone>::clone(base_schema).into_builder();
+        let schema = schema_builder.with_fields(self.fields).build()?;
+        let schema_id = schema.schema_id();
+
+        let updates = vec![
+            TableUpdate::AddSchema { schema },
+            TableUpdate::SetCurrentSchema {
+                schema_id: schema_id + 1,

Review Comment:
   Is this even necessary? Will the new schema version be set to current by 
default? If not, is there a better way to "increment" the schema version?



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to