Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-23968

CTAS with TBLPROPERTIES ('transactional'='false') does not entertain translated table location

    XMLWordPrintableJSON

Details

    Description

      HMS translation layer convert the table to external based on the transactional property set to false but MoveTask does not entertain the translated table location and move the data to the managed table location;

      steps to repro:

      create table nontxnal TBLPROPERTIES ('transactional'='false') as select * from abc;
      

      select query on table return nothing t but the source table has data in it.

      select * from nontxnal;
      +--------------+
      | nontxnal.id  |
      +--------------+
      +--------------+
      

      --show create table

      CREATE EXTERNAL TABLE `nontxnal`(                  |
      |   `id` int)                                        |
      | ROW FORMAT SERDE                                   |
      |   'org.apache.hadoop.hive.ql.io.orc.OrcSerde'      |
      | STORED AS INPUTFORMAT                              |
      |   'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'  |
      | OUTPUTFORMAT                                       |
      |   'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat' |
      | LOCATION                                           |
      |   'hdfs://hostname:8020/warehouse/tablespace/external/hive/nontxnal' |
      | TBLPROPERTIES (                                    |
      |   'TRANSLATED_TO_EXTERNAL'='TRUE',                 |
      |   'bucketing_version'='2',                         |
      |   'external.table.purge'='TRUE',                   |
      |   'transient_lastDdlTime'='1596215634')            |
      
      

      table data is moved to the managed location:
      ```
      dfs -ls -R hdfs://hostname:8020/warehouse/tablespace/managed/hive/nontxnal
      . . . . . . . . . . . . . . . . . . . . . . .> ;
      ----------------------------------------------------

      DFS Output

      ----------------------------------------------------

      rw-rw---+ 3 hive hadoop 201 2020-07-31 17:05 hdfs://hostname:8020/warehouse/tablespace/managed/hive/nontxnal/000000_0

      ----------------------------------------------------

      ```
      The problem seems to be here
      isExternal evaluates to false since the statement is missing external
      https://github.com/apache/hive/blob/d4bfd2ea1ee797f53227f447749cbc97803cd5dc/ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java#L446

      and location return to the managed location
      https://github.com/apache/hive/blob/d4bfd2ea1ee797f53227f447749cbc97803cd5dc/ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java#L455

      Attachments

        Issue Links

          Activity

            People

              Rajkumar Singh Rajkumar Singh
              Rajkumar Singh Rajkumar Singh
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m