Support Questions
Find answers, ask questions, and share your expertise
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

Hive dynamic partition using date

Hi ,

I have some sample date like this



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.????


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.

Don't have an account?
Coming from Hortonworks? Activate your account here