Search code examples
hivehive-partitionshiveddl

Hive External Table is pointing to old location after altering the location to new path


Initially I create a Hive external table following location

hdfs://user/temp2

and then I altered the location to following.

hdfs://user/temp3

Now even after running MSCK repair table my table is pointing to old location (hdfs://user/temp2)

The table is dynamically partitioned.


Solution

  • The thing is your table is partitioned and partitions have their own old locations. For external table the easiest way is to drop and create table + repair table, this will create partitions on top of new location subdirectories.

    Steps to be done are:

    DROP TABLE abc;
    
    CREATE EXTERNAL TABLE abc ... location 'hdfs://user/temp3';
    
    MSCK REPAIR TABLE abc;