Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive dynamic partition using date

Highlighted

Hive dynamic partition using date

New Contributor

Hi ,

I have some sample date like this

1,prasad,Newyork

2,Tarak,Mexico

I want to load this data in to hive table using partition using current date and when I load this data tomorrow again it should be partitioned by using tomorrow's date.

is this possible to achieve this in hive.????

1 REPLY 1

Re: Hive dynamic partition using date

Super Guru
@prasad raju

Yes,Its possible,
Use hive in current_date fucntion to generate the current date

hive> select current_date;
+-------------+--+
|     _c0     |
+-------------+--+
| 2018-06-18  |
+-------------+--+

Your Insert query would be

Insert into <db_name>.<target_tab_name> partition(<field_name>) select *,current_date from <db_name>.<source_tab_name>

By using the above query when you are loading the data to target table the date would be changing dynamically.