prashanth
prashanth

Reputation: 4485

hive error: specifying a string in a hive query

When I run the following hive command

hive -e 'select msg, count(*) as cnt from table where msg like “%abcd%” group by msg order by cnt desc ;' | sed 's/[\t]/,/g' > table.csv

I get the following error.

FAILED: ParseException line 1:89 cannot recognize input near 'like' '%' 'password' in expression specification

I am aware that there is a problem with specifying the string “%abcd%”. The command works fine in a hive environemnt, but here i was trying to save the result to a csv file. How do i rectify this error?

Upvotes: 1

Views: 223

Answers (1)

leftjoin
leftjoin

Reputation: 38290

Hive script should be double-quoted and template is single-quoted:

hive -e "select msg, count(*) as cnt from table where msg like '%abcd%' group by msg order by cnt desc ;" | sed 's/[\t]/,/g' > table.csv

Upvotes: 1

Related Questions