Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-1859

INSERT OVERWRITE with empty result set leaves existing records in partitioned table

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • Impala 2.1.2
    • Impala 2.3.0
    • None
    • CDH 5.3.2 on Ubuntu 14.04.2 LTS

    Description

      Hi,

      It seems doing an INSERT OVERWRITE on a partitioned table with a SELECT that results in no records leaves the existing records in the target table intact. If table is not partitioned it works fine and the result is the truncated table. Table storage type does not seem relevant.

      SQL to reproduce:

      --OK (non-partitioned text table)

      create table t1 (i int);
      insert into t1 values (123);
      create table t2 (i int);
      insert into t2 values (456);
      select count(*) from t2;  --count is 1
      insert overwrite t2 select * from t1 where i < 0;
      select count(*) from t2;  --count is 0
      

      --OK (non-partitioned parquet table)

      create table t1 (i int) stored as parquet;
      insert into t1 values (123);
      create table t2 (i int) stored as parquet;
      insert into t2 values (456);
      select count(*) from t2;  --count is 1
      insert overwrite t2 select * from t1 where i < 0;
      select count(*) from t2;  --count is 0
      

      --WRONG (partitioned text table)

      create table t1 (i int) partitioned by (j int);
      insert into t1 partition (j) values (123, 1);
      create table t2 (i int) partitioned by (j int);
      insert into t2 partition (j) values (456, 2);
      select count(*) from t2;  --count is 1
      insert overwrite t2 partition (j) select * from t1 where j < 0;
      select count(*) from t2;  --ERROR: count is still 1
      

      Thank you,
      Steve

      Attachments

        Activity

          People

            jyu@cloudera.com Juan Yu
            steve77_impala_542a Steven
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: