Support Questions

Find answers, ask questions, and share your expertise

Beeline hivevar value with spaces and symbols

avatar

I am trying to pass a WHERE condition as a variable to hive hql via BeeLine.

--hivevar somekey1='"someValue"'

works well

--hivevar somekey2='"colum1<=someValue"'

does not work which prints the Beeline usage. How can I escape equal to (=)?

Any help or pointers on how I can solve this issue?

5 REPLIES 5

avatar
Master Guru

You can normally escape things with a \ in front of it. Sometimes two backslash.

avatar

@Benjamin Leonhardi

Using \ or \\ does't work. It gives the same error

avatar

@Pooja Chawda

I hope this may help

SELECT packets.sourceip FROM packets WHERE packets.destip = "${hivevar:DEST_IP}" AND packets.hour = ${hivevar:HOUR} GROUP BY packets.sourceip link

avatar
Master Guru

Ok just tried it out. Your problem is that you didn't use the double quotes on the outside. The linux command line needs double quotes to escape strings. You can use single quotes inside.

@Pooja Chawda

[root@sandbox ~]# more test.sql

select * from sample_07 where ${cond};

[root@sandbox ~]# beeline -u jdbc:hive2://sandbox:10000/default -f test.sql --hivevar cond="description='All Occupations'"

...

+-----------------+------------------------+----------------------+-------------------+--+

| sample_07.code | sample_07.description | sample_07.total_emp | sample_07.salary |

+-----------------+------------------------+----------------------+-------------------+--+

| 00-0000 | All Occupations | 134354250 | 40690 |

+-----------------+------------------------+----------------------+-------------------+--+

avatar

Hi all,

I am having the below senario, where the values in where clause is dynamic.

beeline -u jdbc:hive2://<#####>/;auth=noSasl --silent=true --hivevar where_condition=" where modifyts >= '2016-02-18 00:55:43.00' and modifyts < '2016-02-18 00:55:44.0'" --hiveconf hive.auto.convert.join=false --hiveconf hive.optimize.skewjoin=true --hivevar destination_hive_table_name=<table> -f insert_delta_data.hql

22-02-2016 02:51:05 PST beeline_insert_into_k_gvt_inv_node_cntrl_tbl

INFO - Usage: java org.apache.hive.cli.beeline.BeeLine 22-02-2016 02:51:05 PST

beeline_xxxxx INFO - -u the JDBC URL to connect to 22-02-2016 02:51:05 PST

beeline_xxxxx INFO - -n the username to connect as 22-02-2016 02:51:05 PST

beeline_xxxxxNFO - -p the password to connect as 22-02-2016 02:51:05 PST ......................