|
|
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
-
Re: Dynamic "set" command
Edward Capriolo 2012-02-23, 19:11
The support is not there for this. Variables is just string replacement in the CLI. We do not have select without where ' select 1+2' and we have no way to capture a result set and further process it. Most people just do this work outside of hive. On Thu, Feb 23, 2012 at 1:59 PM, Matt Vonkip <[EMAIL PROTECTED]> wrote: > 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
|
|