0

I have a partitioned table Student which already has one partition column dept. I need to add new partition column gender

Will it be possible to add this new partition column in already partitioned hive table.

The table data does not have gender column. It is a new constant column to be added in hive table.

leftjoin
  • 36,950
  • 8
  • 57
  • 116
techie
  • 313
  • 1
  • 8
  • 23
  • I don't know the answer to the question (most probably you can't) but the thing I'm wondering about, does the table data already have the gender inside? If it doesn't, it is better to re-create the table with gender partition – mangusta Aug 13 '19 at 04:37

1 Answers1

1

Partitions are hierarchical folders like table_location/dept=Accounting/gender=male/ Folder structure should exist. You can easily add non-partition column as the last one and it will return NULLs if the data does not contain that column, but to add a partition column the easiest way is to create new table partitioned as you want, insert overwrite that table from the old one (selecting partitions columns as the last ones), drop old table, rename new one.

See this answer about dynamic partitions load: https://stackoverflow.com/a/48901871/2700344

leftjoin
  • 36,950
  • 8
  • 57
  • 116