sankarh commented on a change in pull request #679: HIVE-21764 : REPL DUMP 
should detect and bootstrap any rename table events where old table was 
excluded but renamed table is included.
URL: https://github.com/apache/hive/pull/679#discussion_r296255346
 
 

 ##########
 File path: 
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterTableHandler.java
 ##########
 @@ -82,14 +92,71 @@ private Scenario 
scenarioType(org.apache.hadoop.hive.metastore.api.Table before,
     }
   }
 
+  // return true, if event needs to be dumped, else return false.
+  private boolean handleForTableLevelReplication(Context withinContext) {
+    String oldName = before.getTableName();
+    String newName = after.getTableName();
+
+    if (ReplUtils.tableIncludedInReplScope(withinContext.replScope, oldName)) {
+      // If the table is renamed after being added to the list of tables to be 
bootstrapped, then remove it from the
+      // list of tables to be bootstrapped.
+      boolean oldTableIsPresent = 
withinContext.removeFromListOfTablesForBootstrap(before.getTableName());
+
+      // If old table satisfies the filter, but the new table does not, then 
the old table should be dropped.
+      // This should be done, only if the old table is not in the list of 
tables to be bootstrapped which is a multi
+      // rename case. In case of multi rename, only the first rename should do 
the drop.
+      if (!ReplUtils.tableIncludedInReplScope(withinContext.replScope, 
newName)) {
+        if (oldTableIsPresent) {
+          // If the old table was present in the list of tables to be 
bootstrapped, then just ignore the event.
+          return false;
+        } else {
+          scenario = Scenario.DROP;
+          LOG.info("Table " + oldName + " will be dropped as the table is 
renamed to " + newName);
+          return true;
+        }
+      }
+
+      // If the old table was in the list of tables to be bootstrapped which 
is a multi rename case, the old table
+      // is removed from the list of tables to be bootstrapped and new one is 
added.
+      if (oldTableIsPresent) {
+        withinContext.addToListOfTablesForBootstrap(newName);
+        return false;
+      }
+
+      // If both old and new table satisfies the filter and old table is 
present at target, then dump the rename event.
+      LOG.info("both old and new table satisfies the filter");
+      return true;
+    } else  {
+      // if the old table does not satisfies the filter, but the new one 
satisfies, then the new table should be
+      // added to the list of tables to be bootstrapped and don't dump the 
event.
+      if (ReplUtils.tableIncludedInReplScope(withinContext.replScope, 
newName)) {
+        LOG.info("Table " + newName + " is added for bootstrap " + " during 
rename from " + oldName);
+        withinContext.addToListOfTablesForBootstrap(newName);
+        return false;
+      }
+
+      // if both old and new table does not satisfies the filter, then don't 
dump the event.
+      LOG.info("both old and new table not satisfies the filter");
+      return false;
+    }
+  }
+
   @Override
   public void handle(Context withinContext) throws Exception {
     LOG.info("Processing#{} ALTER_TABLE message : {}", fromEventId(), 
eventMessageAsJSON);
 
     Table qlMdTableBefore = new Table(before);
+    Set<String> bootstrapTableList;
+    if (Scenario.RENAME == scenario) {
+      // Handling for table level replication is done in 
handleForTableLevelReplication method.
+      bootstrapTableList = null;
 
 Review comment:
   ok

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to