You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/08/04 20:51:36 UTC

[GitHub] [hive] cmunkey commented on a diff in pull request #3435: HIVE-24933: Replication fails for transactional tables having same na…

cmunkey commented on code in PR #3435:
URL: https://github.com/apache/hive/pull/3435#discussion_r938223551


##########
ql/src/java/org/apache/hadoop/hive/ql/exec/ReplCopyTask.java:
##########
@@ -166,6 +169,12 @@ public int execute() {
     }
   }
 
+  private void setupWork() throws HiveException {

Review Comment:
   All of these setupWork() implementations are basically the same, can they be moved to base class Task?



##########
ql/src/java/org/apache/hadoop/hive/ql/plan/DeferredWorkHelper.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.plan;
+
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+public interface DeferredWorkHelper {
+  void setupWork(CopyWork copyWork) throws HiveException;
+  void setupWork(ReplCopyWork replCopyWork) throws HiveException;
+  void setupWork(MoveWork moveWork) throws HiveException;

Review Comment:
   If you have interface or abstract that is common to CopyWork, ReplCopyWork, and Move work. And a setupWork() in each of those works.
   This can use be just be one setupWork(DeferredWorkHelper helper).
   
   Interface BaseWork, CopyWork, ReplCopyWork and Move work all implement.
   BaseWork.setupWork(DeferredWorkHelper helper) is the method that they all have to implement.
   
   For instance CopyWork.setupWork(DeferredWorkHelper helper) {
        ImportSemanticAnalyzer.evaluate(helper.getReplace(), helper.getTgtPath(), helper.getWriteId(), helper.getStmtId(), helper.getHive(), helper.getCtx(), helper.getTblDesc(), helper.getInReplScope(), helper);
       this.setToPath(new Path[] { destPath });
     }
   }
   
   
   



##########
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java:
##########
@@ -3408,4 +3411,83 @@ public void testTableWithPartitionsInBatch() throws Throwable {
       .verifyResults(new String[] { "bangalore", "paris", "sydney" })
       .verifyReplTargetProperty(replicatedDbName);
   }
+
+
+  @Test
+  public void testTxnTblReplWithSameNameAsDroppedNonTxnTbl() throws Throwable {
+    List<String> withClauseOptions = new LinkedList<>();
+    withClauseOptions.add("'" + HiveConf.ConfVars.HIVE_DISTCP_DOAS_USER.varname
+        + "'='" + UserGroupInformation.getCurrentUser().getUserName() + "'");
+
+    String tbl = "t1";
+    primary
+        .run("use " + primaryDbName)
+        .run("create table " + tbl + " (id int)")
+        .run("insert into table " + tbl + " values (1)")
+        .dump(primaryDbName, withClauseOptions);
+
+    replica
+        .load(replicatedDbName, primaryDbName)
+        .run("use " + replicatedDbName)
+        .run("select id from " + tbl)
+        .verifyResults(new String[] {"1"});
+
+    assertFalse(AcidUtils.isTransactionalTable(replica.getTable(replicatedDbName, tbl)));
+
+    primary
+        .run("use " + primaryDbName)
+        .run("drop table " + tbl)
+        .run("create table " + tbl + " (id int) clustered by(id) into 3 buckets stored as orc " +
+            "tblproperties (\"transactional\"=\"true\")")
+        .run("insert into table " + tbl + " values (2)")
+        .dump(primaryDbName, withClauseOptions);
+
+    replica
+        .load(replicatedDbName, primaryDbName)
+        .run("use " + replicatedDbName)
+        .run("select id from " + tbl)
+        .verifyResults(new String[] {"2"});
+
+    assertTrue(AcidUtils.isTransactionalTable(replica.getTable(replicatedDbName, tbl)));
+  }
+
+  @Test
+  public void testTxnTblReplWithSameNameAsDroppedExtTbl() throws Throwable {

Review Comment:
   What type is the table dropped in testTxnTblReplWithSameNameAsDroppedNonTxnTbl?
   Here it is external, is there a managed one?



-- 
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-unsubscribe@hive.apache.org

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


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