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

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

                Author: ASF GitHub Bot
            Created on: 07/Jul/21 13:25
            Start Date: 07/Jul/21 13:25
    Worklog Time Spent: 10m 
      Work Description: nrg4878 commented on a change in pull request #2442:
URL: https://github.com/apache/hive/pull/2442#discussion_r665364292



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java
##########
@@ -472,6 +473,25 @@ private void setLoadFileLocation(
       loc = cmv.getLocation();
     }
     Path location = (loc == null) ? getDefaultCtasLocation(pCtx) : new 
Path(loc);
+    boolean isExternal = false;
+    boolean isAcid = false;
+    if (pCtx.getQueryProperties().isCTAS()) {
+      isExternal = pCtx.getCreateTable().isExternal();
+      isAcid = pCtx.getCreateTable().getTblProps().getOrDefault(
+              hive_metastoreConstants.TABLE_IS_TRANSACTIONAL, 
"false").equalsIgnoreCase("true") ||
+              
pCtx.getCreateTable().getTblProps().containsKey(hive_metastoreConstants.TABLE_TRANSACTIONAL_PROPERTIES);
+      if(location != null && (HiveConf.getBoolVar(conf, 
HiveConf.ConfVars.CREATE_TABLE_AS_EXTERNAL) || (isExternal || !isAcid))){
+        CreateTableDesc ctd = pCtx.getCreateTable();
+        ctd.setLocation(location.toString());

Review comment:
       Shouldn't this be set regardless of the ACID properties on the table? if 
location is not null, we should always set it on the CreateTableDescriptor 
right ?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java
##########
@@ -472,6 +473,25 @@ private void setLoadFileLocation(
       loc = cmv.getLocation();
     }
     Path location = (loc == null) ? getDefaultCtasLocation(pCtx) : new 
Path(loc);
+    boolean isExternal = false;
+    boolean isAcid = false;
+    if (pCtx.getQueryProperties().isCTAS()) {
+      isExternal = pCtx.getCreateTable().isExternal();
+      isAcid = pCtx.getCreateTable().getTblProps().getOrDefault(
+              hive_metastoreConstants.TABLE_IS_TRANSACTIONAL, 
"false").equalsIgnoreCase("true") ||
+              
pCtx.getCreateTable().getTblProps().containsKey(hive_metastoreConstants.TABLE_TRANSACTIONAL_PROPERTIES);
+      if(location != null && (HiveConf.getBoolVar(conf, 
HiveConf.ConfVars.CREATE_TABLE_AS_EXTERNAL) || (isExternal || !isAcid))){
+        CreateTableDesc ctd = pCtx.getCreateTable();
+        ctd.setLocation(location.toString());
+        
if(ctd.getSerdeProps().containsKey(hive_metastoreConstants.TABLE_TRANSACTIONAL_PROPERTIES)){
+          
ctd.getSerdeProps().remove(hive_metastoreConstants.TABLE_TRANSACTIONAL_PROPERTIES);

Review comment:
       would the SerdeProps also have the ACID properties set? Where are these 
being set and used?
   also we can just do a ctd.getSerdeProps().remove() directly without the 
containsKey() check.




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


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

    Worklog Id:     (was: 619975)
    Time Spent: 20m  (was: 10m)

> CTAS hive.create.as.external.legacy tries to place data files in managed WH 
> path
> --------------------------------------------------------------------------------
>
>                 Key: HIVE-25303
>                 URL: https://issues.apache.org/jira/browse/HIVE-25303
>             Project: Hive
>          Issue Type: Bug
>          Components: HiveServer2, Standalone Metastore
>            Reporter: Sai Hemanth Gantasala
>            Assignee: Sai Hemanth Gantasala
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Under legacy table creation mode (hive.create.as.external.legacy=true), when 
> a database has been created in a specific LOCATION, in a session where that 
> database is USEd, tables created using
> CREATE TABLE <tablename> AS SELECT <select statement>
> should inherit the HDFS path from the database's location.
> Instead, Hive is trying to write the table data into 
> /warehouse/tablespace/managed/hive/<database_directory_name>/<table_name>



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to