zhangbutao commented on code in PR #5222:
URL: https://github.com/apache/hive/pull/5222#discussion_r1584269516


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/mapreduce/IcebergInputFormat.java:
##########
@@ -424,6 +426,12 @@ private CloseableIterable<T> openGeneric(FileScanTask 
task, Schema readSchema) {
           iterable = newOrcIterable(inputFile, task, readSchema);
           break;
         case PARQUET:
+          if (inputFile instanceof HadoopInputFile) {

Review Comment:
   What's the change meaning? Is it related the replace tag?



##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergTagExec.java:
##########
@@ -64,4 +64,13 @@ public static void dropTag(Table table, 
AlterTableSnapshotRefSpec.DropSnapshotRe
       table.manageSnapshots().removeTag(tagName).commit();
     }
   }
+
+  public static void replaceTag(Table table, 
AlterTableSnapshotRefSpec.ReplaceSnapshotrefSpec replaceTagRefSpec) {
+    String sourceTag = replaceTagRefSpec.getSourceRefName();
+    long targetSnapshot = replaceTagRefSpec.getTargetSnapshot();
+    LOG.info("Replacing tag {} with snapshot {} on iceberg table {}", 
sourceTag, targetSnapshot, table.name());
+    ManageSnapshots manageSnapshots = 
table.manageSnapshots().replaceTag(sourceTag, targetSnapshot);
+    IcebergBranchExec.setOptionalReplaceParams(replaceTagRefSpec, 
manageSnapshots, sourceTag);

Review Comment:
   I know this line want to reuse `IcebergBranchExec `code to reduce code 
duplication. But my original thought was to keep Branch and Tag operation 
separate.
   
   I am not aginst doing this as Branch and Tag operation indeed have many 
similar code.
   1) Maybe we can merge the two  `IcebergBranchExec ` & `IcebergTagExec ` into 
one class. 
   2) Or we can extract the common codes and put it into the utility class. 
   This optimization can be done once branch&tag feature are all done in the 
future. :)



##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSnapshotOperations.java:
##########
@@ -116,4 +117,47 @@ public void testReplaceBranchWithSnapshot() {
     result = shell.executeStatement("SELECT COUNT(*) FROM 
default.testReplaceBranchWithSnapshot.branch_branch1");
     assertEquals(6L, result.get(0)[0]);
   }
+
+  @Test
+  public void testReplaceTag() {

Review Comment:
   We already have `TestHiveIcebergTagOperation `& 
`TestHiveIcebergBranchOperation`. Should we put the branch&tag operation into 
there?



##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/snapshotref/tag/replace/AlterTableReplaceTagRefAnalyzer.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+package org.apache.hadoop.hive.ql.ddl.table.snapshotref.tag.replace;
+
+import java.util.Map;
+
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory;
+import org.apache.hadoop.hive.ql.ddl.DDLUtils;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.ddl.table.AbstractAlterTableAnalyzer;
+import org.apache.hadoop.hive.ql.ddl.table.AbstractAlterTableDesc;
+import org.apache.hadoop.hive.ql.ddl.table.AlterTableType;
+import 
org.apache.hadoop.hive.ql.ddl.table.snapshotref.AlterTableSnapshotRefDesc;
+import 
org.apache.hadoop.hive.ql.ddl.table.snapshotref.branch.replace.AlterTableReplaceBranchRefAnalyzer;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.hooks.ReadEntity;
+import org.apache.hadoop.hive.ql.metadata.Table;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.AlterTableSnapshotRefSpec;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+
+@DDLSemanticAnalyzerFactory.DDLType(types = 
HiveParser.TOK_ALTERTABLE_REPLACE_TAG)
+public class AlterTableReplaceTagRefAnalyzer extends 
AbstractAlterTableAnalyzer {

Review Comment:
   It would be good if we can merge `AlterTableReplaceTagRefAnalyzer` & 
`AlterTableReplaceBranchRefAnalyzer` into one class.



-- 
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: gitbox-unsubscr...@hive.apache.org

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


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

Reply via email to