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

When table is renamed stats are lost as changes are not propagated to metastore tables TAB_COL_STATS and PART_COL_STATS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.14.0, 1.0.0, 1.1.0
    • 1.2.0
    • Metastore

    Description

      When a Hive table is renamed that the name is not updated in TAB_COL_STATS and PART_COL_STATS.

      Repro
      1) Create table
      2) insert rows
      3) Analyze table t1 compute statistics for columns;
      4) set hive.stats.fetch.column.stats=true;
      5) Explain select * from t1 where c1 > x
      6) ALTER TABLE t1 RENAME TO 2;
      7) Explain select * from t2 where c1 > x ; /* stats will be missing */
      8) Query the Metastore tables to validate

      According to the documentation Metastore should be updated

      This statement lets you change the name of a table to a different name.
      As of version 0.6, a rename on a managed table moves its HDFS location as well. (Older Hive versions just renamed the table in the metastore without moving the HDFS location.)
      

      Another related issue is that the schema of the stats table is not consistent with TBLS and DBS as these two table are normalized while TAB_COL_STATS and PART_COL_STATS have TABLE_NAME and DB_NAME denormalized in them.

      Attachments

        Issue Links

          Activity

            People

              ashutoshc Ashutosh Chauhan
              mmokhtar Mostafa Mokhtar
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: