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

 ##########
 File path: ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java
 ##########
 @@ -398,11 +398,20 @@ public int execute(DriverContext driverContext) {
         // for transactional table if write id is not set during replication 
from a cluster with STRICT_MANAGED set
         // to false then set it now.
         if (tbd.getWriteId() <= 0 && 
AcidUtils.isTransactionalTable(table.getParameters())) {
-          Long writeId = ReplUtils.getMigrationCurrentTblWriteId(conf);
-          if (writeId == null) {
-            throw new HiveException("MoveTask : Write id is not set in the 
config by open txn task for migration");
+          if (work.getIsInReplicationScope()) {
+            Long writeId = ReplUtils.getMigrationCurrentTblWriteId(conf);
+            if (writeId == null) {
+              throw new HiveException("MoveTask : Write id is not set in the 
config by open txn task for migration");
+            }
+            tbd.setWriteId(writeId);
+          } else if (tbd.isCtas()) {
+            // In CTAS flow, the table may not have got created when creating 
load table task.
+            // So, fetch the writeId here from the table.
+            tbd.setWriteId(table.getTTable().getWriteId());
 
 Review comment:
   Shall use 
driverContext.getCtx().getHiveTxnManager().getAllocatedTableWriteId as we are 
not sure if writeId is always set in table object. 

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