maheshk114 commented on a change in pull request #614: HIVE-21678
URL: https://github.com/apache/hive/pull/614#discussion_r281910004
 
 

 ##########
 File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
 ##########
 @@ -7477,18 +7477,30 @@ protected Operator genFileSinkPlan(String dest, QB qb, 
Operator input)
         fileSinkColInfos = new ArrayList<>();
         destTableIsTemporary = tblDesc.isTemporary();
         destTableIsMaterialization = tblDesc.isMaterialization();
-        if (AcidUtils.isInsertOnlyTable(tblDesc.getTblProps(), true)) {
-          isMmTable = isMmCtas = true;
+        if (AcidUtils.isTablePropertyTransactional(tblDesc.getTblProps())) {
           try {
             if (ctx.getExplainConfig() != null) {
               writeId = 0L; // For explain plan, txn won't be opened and 
doesn't make sense to allocate write id
             } else {
-              writeId = txnMgr.getTableWriteId(tblDesc.getDatabaseName(), 
tblDesc.getTableName());
+              String dbName = tblDesc.getDatabaseName();
+              String tableName = tblDesc.getTableName();
+
+              // CreateTableDesc stores table name as db.table. So, need to 
decode it before allocating
+              // write id.
+              if ((dbName == null) || tableName.contains(".")) {
+                String[] names = Utilities.getDbTableName(tableName);
+                dbName = names[0];
+                tableName = names[1];
+              }
+              writeId = txnMgr.getTableWriteId(dbName, tableName);
             }
           } catch (LockException ex) {
             throw new SemanticException("Failed to allocate write Id", ex);
           }
-          tblDesc.setInitialMmWriteId(writeId);
+          if (AcidUtils.isInsertOnlyTable(tblDesc.getTblProps(), true)) {
+            isMmTable = isMmCtas = true;
+            tblDesc.setInitialMmWriteId(writeId);
 
 Review comment:
   write id should be set in tbldesc ?

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