Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive, mail # user - Dynamic "set" command


Copy link to this message
-
Dynamic "set" command
Matt Vonkip 2012-02-23, 18:59
Hi folks,

I am running a hive script that currently takes in the variables T, T_PREV, etc.  These are used for, amonst other things, adding paritions.  For example:

alter table my_table add if not exists partition (dt='${T}');
alter table my_table add if not exists partition (dt='${T_PREV}');
The format of T, T_PREV, and subsequent variables is 'yyyy-MM-dd-HH'.  I'd like to pass in only T and calculate the others in the .q script.  In MySQL, I'd do this by setting a local variable (hiveconf domain?) based on a calculation (e.g., convert to unix_timestamp, subtract an hour, convert back to string).  But I can't seem to find a way to do this dynamically in Hive.  Am I missing something?

Sincerely,
Matt VonKip