Different Hive location for different commands

Viewed 34

I have a hive external table in my production (let's say table1). When I do desc formatted table1 I can see some location. When I do desc formatted table1 partition(date = 22042019) instead, it's getting different hdfs location.

E.g:

desc formatted table1

Location: user/hive/warehouse/db.db/loc1

Desc formatted table1 partition (date = 22042019")

Location: x/y/loc/date=22042019
1 Answers

Table and partition locations can be different. When you are adding partition without specifying location or dynamically creating partitions during insert, partition folders normally created inside table location. But you can use alter table add partition ...location ... or [alter table partition set location][1] In this case you can create partitions outside table location. Also you can alter table set location and set different location. All existing partitions and their locations in this case will remain as is and be accessible, though their base location and table location are different.

Related