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

User is not able to drop table

    XMLWordPrintableJSON

Details

    Description

      Hive won't store anything in TAB_COL_STATS for partitioned table, whereas impala stores complete column stats in TAB_COL_STATS for partitioned table. Deleting entries in TAB_COL_STATS is based on (DB_NAME, TABLE_NAME), not by TBL_ID. Renamed tables were having old names in TAB_COL_STATS.

      To Repro:

      beeline:
      set hive.create.as.insert.only=false;
      set hive.create.as.acid=false;
      create table testes.table_name_with_partition (id tinyint, name string) partitioned by (col_to_partition bigint) stored as parquet;
      insert into testes.table_name_with_partition (id, name, col_to_partition) values (1, "a", 2020), (2, "b", 2021), (3, "c", 2022);
      
      impala:
      compute stats testes.table_name_with_partition; -- backend shows new entries in TAB_COL_STATS
      
      beeline:
      alter table testes.table_name_with_partition rename to testes2.table_that_cant_be_droped;
      drop table testes2.table_that_cant_be_droped; -- This fails with TAB_COL_STATS_fkey constraint violation.
      

      Exception trace for drop table failure

      Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "TBLS" violates foreign key constraint "TAB_COL_STATS_fkey" on table "TAB_COL_STATS"
        Detail: Key (TBL_ID)=(19816) is still referenced from table "TAB_COL_STATS".
              at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
              at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
              ... 50 more
      

      Attachments

        Issue Links

          Activity

            People

              veghlaci05 László Végh
              veghlaci05 László Végh
              Votes:
              0 Vote for this issue
              Watchers:
              1 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 - 2h 50m
                  2h 50m