I'm rather new to Hive so be gentle... I have a large table in Hive, and one of the columns has dollar signs in it's values, for example "123$AB". I want to filter the table using this column:
select * from foo where bar = "123$AB"
Seemed simple but when I executed the query, I got a prompt asking for input: "Please specify parameters for this query: AB ________"
A bit of research turned up this: How to set variables in HIVE scripts
I guess Hive is seeing the dollar sign and thinking I want to input a variable or something. OK, so we need to escape the dollar sign.
I tried the following:
select * from foo where bar = "123\$AB"
select * from foo where bar = "123\\$AB"
select * from foo where bar = '123$AB'
select * from foo where bar = '123\$AB'
select * from foo where bar = '123\\$AB'
but I keep getting the same prompt. It just won't recognize '$' as a character. How do I escape the '$'?
For now I am doing the following:
select * from foo where substr(bar,1,3) = '123'
which works fine for now but I still want to know how to escape special characters. Thanks!
EDIT: Workaround available - see comments!
EDIT 2: To the left of the query editor is a "Settings" tab, and at the bottom of the settings tab is "OPTIONS: Enable parameterization". I didn't realize what this was until now. I should have unchecked this, which would have solved my problem. However, the problem still exists; if there was a situation where I wanted to use a parameter variable, as well as a character string containing a dollar sign.