Hi Praveen
        It is not a hive issue, a minor shell script issue. You are passing the 
string value "TABLE_NAME1" to .hql where as you intended to pass the value of 
variable TABLE_NAME1 to .hql . For that include a $ sign in front of variable 
names like

hive -f hive_query.hql -hiveconf tab_name1=$TABLE_NAME1 -hiveconf 
tab_name2=$TABLE_NAME2 -hiveconf curr_date1=$CURRENT_DATE1 -hiveconf 
curr_date2=$CURRENT_DATE2

Also in your HQLno need of quotes for table names

select * from ( select * from ${hiveconf:tab_name1} union all select * from 
${hiveconf: tab_name2}) t1 ...

Hope it helps!..

Regards
Bejoy.K.S



________________________________
 From: Praveen Kumar <praveenshett...@gmail.com>
To: user@hive.apache.org 
Sent: Wednesday, January 11, 2012 3:44 PM
Subject: Re: Date,table name as config parameter from command prompt in Hive 
queries
 

I found one way of doing it but, failing in that.

hive_query.hql
--------------
use db_name;
select * from ( select * from '${hiveconf:tab_name1}' union all select * from 
'${hiveconf: tab_name2}') t1 
where sdate > '${hiveconf: curr_date1}' and edate < '${hiveconf: curr_date2}';

hive_tri.sh
-------------
TABLE_NAME1=$1
TABLE_NAME2=$2
CURRENT_DATE1=$3
CURRENT_DATE2=$4
hive -f hive_query.hql -hiveconf tab_name1=TABLE_NAME1 -hiveconf 
tab_name2=TABLE_NAME2 -hiveconf curr_date1=CURRENT_DATE1 -hiveconf 
curr_date2=CURRENT_DATE2


from prompt I am running below query,

$ ./hive_tri.sh temp_table real_table 2011-12-10 2011-12-23


But, after running above command I am getting error:
FAILED: Parse Error: line 2:31 cannot recognize input ''TABLE_NAME1'' in join 
source

please help where I it is going wrong

Thanks
Praveen




On Wed, Jan 11, 2012 at 3:15 PM, Praveen Kumar <praveenshett...@gmail.com> 
wrote:

Hello,
>
>I want to run hive queries through a .hql file in command prompt where i need 
>to pass start_date,end_date & table_name as command line parameter
>How can I achieve this?
>Please help
>
>-- 
>
>Regards,
>Praveen
>


-- 

Regards,
Praveen

Reply via email to