sankarh commented on a change in pull request #688: HIVE-21886 : REPL - With 
table list - Handle rename events during replace policy
URL: https://github.com/apache/hive/pull/688#discussion_r297611643
 
 

 ##########
 File path: 
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterTableHandler.java
 ##########
 @@ -92,16 +93,40 @@ 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();
+  private boolean isSetForBootstrapByReplaceHandler(Context withinContext, 
String tblName) {
+    return (withinContext.oldReplScope != null)
+            && 
!(ReplUtils.tableIncludedInReplScope(withinContext.oldReplScope, tblName))
+            && (ReplUtils.tableIncludedInReplScope(withinContext.replScope, 
tblName));
+  }
 
-    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());
+  // Return true, if event needs to be dumped, else return false.
+  private boolean handleForTableLevelReplication(Context withinContext, String 
tblName) {
+    // For alter, if the table does not satisfy the new policy then ignore the 
event. In case of replace
+    // policy, if the table does not satisfy the old policy, then ignore the 
event. As, if the table satisfy the new
+    // policy, then the table will be bootstrapped by replace handler anb if 
the table does not satisfy the new policy,
+    // then anyways the table should be ignored.
+    if (!ReplUtils.tableIncludedInReplScope(withinContext.replScope, tblName)) 
{
+      // In case of replace, it will be dropped during load. In normal case 
just ignore the alter event.
+      LOG.debug("Table " + tblName + " does not satisfy the policy");
+      return false;
+    } else if ((withinContext.oldReplScope != null)
+            && 
(!ReplUtils.tableIncludedInReplScope(withinContext.oldReplScope, tblName))) {
+      LOG.debug("Table " + tblName + " is set for bootstrap");
+      return false;
+    } else {
+      // Table satisfies both old (if its there) and current policy, dump the 
alter event.
+      return true;
+    }
+  }
 
+  // Return true, if event needs to be dumped, else return false.
+  private boolean handleForTableLevelReplicationForRename(Context 
withinContext, String oldName, String newName) {
 
 Review comment:
   Out of context of this patch. Since, dynamic bootstrap have issues(such as 
bootstrapping wrong tables, subsequent REPL DUMP includes events on old table 
etc) if user specifies TO or LIMIT clause in REPL DUMP, should we validate it 
and return error if table level replication is enabled in repl policy. 

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