deniskuzZ commented on code in PR #5648:
URL: https://github.com/apache/hive/pull/5648#discussion_r1977441673


##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java:
##########
@@ -1800,17 +1800,11 @@ public Table getTable(final String dbName, final String 
tableName, String tableM
    * @throws LockException
    */
   private ValidWriteIdList getValidWriteIdList(String dbName, String 
tableName) throws LockException {
-    ValidWriteIdList validWriteIdList = null;
-    SessionState sessionState = SessionState.get();
-    HiveTxnManager txnMgr = sessionState != null? sessionState.getTxnMgr() : 
null;
-    long txnId = txnMgr != null ? txnMgr.getCurrentTxnId() : 0;
-    if (txnId > 0) {
-      validWriteIdList = AcidUtils.getTableValidWriteIdListWithTxnList(conf, 
dbName, tableName);
-    } else {
-      String fullTableName = getFullTableName(dbName, tableName);
-      validWriteIdList = new ValidReaderWriteIdList(fullTableName, new 
long[0], new BitSet(), Long.MAX_VALUE);
-    }
-    return validWriteIdList;
+    long txnId = Optional.ofNullable(SessionState.get())
+      .map(ss -> ss.getTxnMgr().getCurrentTxnId()).orElse(0L);
+    
+    return (txnId > 0) ? AcidUtils.getTableValidWriteIdListWithTxnList(conf, 
dbName, tableName) : 
+        new ValidReaderWriteIdList();

Review Comment:
   if there is no txnId for an ACID table - that's wrong and we can return just 
a dummy



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

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


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

Reply via email to