[ 
https://issues.apache.org/jira/browse/HIVE-26217?focusedWorklogId=776208&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-776208
 ]

ASF GitHub Bot logged work on HIVE-26217:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 31/May/22 10:25
            Start Date: 31/May/22 10:25
    Worklog Time Spent: 10m 
      Work Description: deniskuzZ commented on code in PR #3281:
URL: https://github.com/apache/hive/pull/3281#discussion_r885441938


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -7940,6 +7970,46 @@ protected Operator genFileSinkPlan(String dest, QB qb, 
Operator input)
     return output;
   }
 
+  private Path getCTASDestinationTableLocation(CreateTableDesc tblDesc, 
boolean enableSuffixing) throws SemanticException {
+    Path location;
+    String suffix = "";
+    try {
+      // When location is specified, suffix is not added
+      if (tblDesc.getLocation() == null) {
+        String protoName = tblDesc.getDbTableName();
+        String[] names = Utilities.getDbTableName(protoName);
+        if (enableSuffixing) {
+          long txnId = ctx.getHiveTxnManager().getCurrentTxnId();
+          suffix = SOFT_DELETE_PATH_SUFFIX + String.format(DELTA_DIGITS, 
txnId);
+        }
+        if (!db.databaseExists(names[0])) {
+          throw new SemanticException("ERROR: The database " + names[0] + " 
does not exist.");
+        }
+
+        Warehouse wh = new Warehouse(conf);
+        location = wh.getDefaultTablePath(db.getDatabase(names[0]), names[1] + 
suffix, false);
+      } else {
+        location = new Path(tblDesc.getLocation());
+      }
+
+      // Handle table translation
+      // Property modifications of the table is handled later.
+      // We are interested in the location if it has changed
+      // due to table translation.
+      Table tbl = tblDesc.toTable(conf);
+      tbl = db.getTranslateTableDryrun(tbl.getTTable());

Review Comment:
   shouldn't we pass through the transformers first and do the location check 
after?
   ````
   tbl = db.getTranslateTableDryrun(tbl.getTTable());
   if (tbl.getSd().getLocation() == null
               || tbl.getSd().getLocation().isEmpty()) {
        location = wh.getDefaultTablePath(db.getDatabase(names[0]), names[1], 
false);
   } else {
       location = wh.getDnsPath(new Path(tbl.getSd().getLocation()));
   }
   tbl.getSd().setLocation(location.toString());
   ```` 





Issue Time Tracking
-------------------

    Worklog Id:     (was: 776208)
    Time Spent: 8h 20m  (was: 8h 10m)

> Make CTAS use Direct Insert Semantics
> -------------------------------------
>
>                 Key: HIVE-26217
>                 URL: https://issues.apache.org/jira/browse/HIVE-26217
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Sourabh Badhya
>            Assignee: Sourabh Badhya
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 8h 20m
>  Remaining Estimate: 0h
>
> CTAS on transactional tables currently does a copy from staging location to 
> table location. This can be avoided by using Direct Insert semantics. Added 
> support for suffixed table locations as well.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to