sankarh commented on a change in pull request #664: HIVE-21762: REPL DUMP to 
support new format for replication policy input to take included tables list.
URL: https://github.com/apache/hive/pull/664#discussion_r292993249
 
 

 ##########
 File path: 
ql/src/java/org/apache/hadoop/hive/ql/parse/ReplicationSemanticAnalyzer.java
 ##########
 @@ -173,67 +184,38 @@ private void initReplDump(ASTNode ast) throws 
HiveException {
           break;
         }
         case TOK_REPL_TABLES: {
-          assert(currNode.getChildCount() <= 2);
-          if (!isValidTablesList(currNode)) {
-            LOG.error(ErrorMsg.REPL_INCORRECT_SYNTAX_FOR_REPL_POLICY.getMsg());
-            throw new 
SemanticException(ErrorMsg.REPL_INCORRECT_SYNTAX_FOR_REPL_POLICY.getMsg());
-          }
-
-          // Traverse the children which can be single table_name node or just 
include tables list
-          // or both include and exclude tables list.
-          for (int listIdx = 0; listIdx < currNode.getChildCount(); listIdx++) 
{
-            Tree tablesNode = currNode.getChild(listIdx);
-            if (tablesNode.getType() == TOK_TABNAME) {
-              String tableName = tablesNode.getChild(0).getText();
-              LOG.info("ReplScope: Set Table Name: {}", tableName);
-              replScope.setTableName(tableName);
-            } else {
-              List<String> tablesList = new ArrayList<>();
-              for (int child = 0; child < tablesNode.getChildCount(); child++) 
{
-                Tree tablePatternNode = tablesNode.getChild(child);
-                if (tablePatternNode.getType() == TOK_NULL) {
-                  
LOG.error(ErrorMsg.REPL_INVALID_DB_OR_TABLE_PATTERN.getMsg());
-                  throw new 
SemanticException(ErrorMsg.REPL_INVALID_DB_OR_TABLE_PATTERN.getMsg());
-                }
-                tablesList.add(unescapeSQLString(tablePatternNode.getText()));
-              }
-              if (!tablesList.isEmpty()) {
-                if (listIdx == 0) {
-                  LOG.info("ReplScope: Set Included Tables List: {}", 
tablesList);
-                  replScope.setIncludedTablePatterns(tablesList);
-                } else {
-                  LOG.info("ReplScope: Set Excluded Tables List: {}", 
tablesList);
-                  replScope.setExcludedTablePatterns(tablesList);
-                }
-              }
-            }
-          }
+          setReplDumpTablesList(currNode);
           break;
         }
-        default: {
+        case TOK_FROM: {
           // TOK_FROM subtree
           Tree fromNode = currNode;
           eventFrom = 
Long.parseLong(PlanUtils.stripQuotes(fromNode.getChild(0).getText()));
-          // skip the first, which is always required
-          int numChild = 1;
-          while (numChild < fromNode.getChildCount()) {
-            if (fromNode.getChild(numChild).getType() == TOK_TO) {
+
+          // Skip the first, which is always required
+          int fromChildIdx = 1;
+          while (fromChildIdx < fromNode.getChildCount()) {
+            if (fromNode.getChild(fromChildIdx).getType() == TOK_TO) {
               eventTo =
-                      
Long.parseLong(PlanUtils.stripQuotes(fromNode.getChild(numChild + 
1).getText()));
-              // skip the next child, since we already took care of it
-              numChild++;
-            } else if (fromNode.getChild(numChild).getType() == TOK_LIMIT) {
+                      
Long.parseLong(PlanUtils.stripQuotes(fromNode.getChild(fromChildIdx + 
1).getText()));
+              // Skip the next child, since we already took care of it
+              fromChildIdx++;
+            } else if (fromNode.getChild(fromChildIdx).getType() == TOK_LIMIT) 
{
               maxEventLimit =
-                      
Integer.parseInt(PlanUtils.stripQuotes(fromNode.getChild(numChild + 
1).getText()));
-              // skip the next child, since we already took care of it
-              numChild++;
+                      
Integer.parseInt(PlanUtils.stripQuotes(fromNode.getChild(fromChildIdx + 
1).getText()));
+              // Skip the next child, since we already took care of it
+              fromChildIdx++;
             }
             // move to the next child in FROM tree
-            numChild++;
+            fromChildIdx++;
           }
+          break;
+        }
+        default: {
+          throw new SemanticException("Unrecognized token in REPL DUMP 
statement.");
 
 Review comment:
   Done

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