kishendas commented on a change in pull request #1095:
URL: https://github.com/apache/hive/pull/1095#discussion_r443069237



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
##########
@@ -12308,16 +12303,99 @@ else if(ast.getChild(0).getType() == 
HiveParser.TOK_FALSE) {
       // if phase1Result false return
       return false;
     }
+
+    // 5. Set write id for HMS client
+    if (getTxnMgr().supportsAcid() && 
conf.get(ValidTxnWriteIdList.VALID_TABLES_WRITEIDS_KEY) == null) {
+
+      ValidTxnWriteIdList txnWriteIds = null;
+
+      if (conf.get(ValidTxnWriteIdList.COMPACTOR_VALID_TABLES_WRITEIDS_KEY) != 
null) {
+        txnWriteIds = new 
ValidTxnWriteIdList(conf.getLong(ValidTxnList.COMPACTOR_VALID_TXNS_ID_KEY, 0));
+        txnWriteIds.addTableValidWriteIdList(
+            new 
ValidReaderWriteIdList(conf.get(ValidTxnWriteIdList.COMPACTOR_VALID_TABLES_WRITEIDS_KEY)));
+      } else {
+        List<String> tabNames = new ArrayList<>();
+        for (String tabName : collectTables(qb)) {
+          String fullName = TableName
+              .fromString(tabName, SessionState.get().getCurrentCatalog(), 
SessionState.get().getCurrentDatabase())
+              .getDbTable();
+          tabNames.add(fullName);
+        }
+
+        if (!tabNames.isEmpty()) {
+          String txnString = conf.get(ValidTxnList.VALID_TXNS_KEY);
+
+          try {
+            if ((txnString == null) || (txnString.isEmpty())) {
+              txnString = getTxnMgr().getValidTxns().toString();
+              conf.set(ValidTxnList.VALID_TXNS_KEY, txnString);
+            }
+
+            txnWriteIds = getTxnMgr().getValidWriteIds(tabNames, txnString);
+          } catch (LockException e) {
+            throw new SemanticException("Failed to fetch write Id from 
TxnManager", e);
+          }
+        }
+      }
+
+      if (txnWriteIds != null) {

Review comment:
       Probably you are getting confused. We are not allocating any write ID 
here, just populating the ValidWriteIdList. 
driverContext.getTxnManager().getTableWriteId() is the one that allocates a 
write ID, although even that method name is confusing !




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



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

Reply via email to