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

explain CTAS fails if the table already exists

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 2.0.0
    • Component/s: Hive
    • Labels:
      None
    • Target Version/s:

      Description

      Explain of a CTAS will fail if the table already exists.

      This is an annoyance when you're seeing if a large body of SQL queries will function by putting explain in front of every query.

      hive> create table temp (x int);
      OK
      Time taken: 0.252 seconds
      hive> create table temp2 (x int);
      OK
      Time taken: 0.407 seconds
      hive> explain create table temp as select * from temp2;
      FAILED: SemanticException org.apache.hadoop.hive.ql.parse.SemanticException: Table already exists: mydb.temp
      

      If we compare to Postgres "The Zinc Standard of SQL Compliance":

      carter=# create table temp (x int);
      CREATE TABLE
      carter=# create table temp2 (x int);
      CREATE TABLE
      carter=# explain create table temp as select * from temp2;
                             QUERY PLAN
      ---------------------------------------------------------
       Seq Scan on temp2  (cost=0.00..34.00 rows=2400 width=4)
      (1 row)
      

      If the CTAS is something complex it would be nice to see the query plan in advance.

        Attachments

        1. HIVE-12311.1.patch
          23 kB
          Gunther Hagleitner

          Activity

            People

            • Assignee:
              hagleitn Gunther Hagleitner
              Reporter:
              cartershanklin Carter Shanklin
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: