hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chen Song <chens_alb...@yahoo.com>
Subject Question on escaped characters in Hive Shell
Date Thu, 01 Mar 2012 16:42:34 GMT
Hi All

I have a question on quoted hive query when executed with 'hive -e'. The command I ran looks
like:

> hive -e "select regexp_extract(col1, '\\d+') from A where col2='some value' limit 5"

When the query get passed into hive, it is interpreted as

> select regexp_extract(col1, \d+') from A where col2='some value' limit 5

As you can see, the regex patten is translated from '\\d+' to '\d+' due to the escape character.

By using single quote at the outer level and double quotes within query itself, I can get
around this problem. It also works by putting the query in a file and running with 'hive -f'.
But both approaches needs amendments to the application and sounds a little tactical.

My questions are

1) Does hive handle escaping or the linux shell interprete it before passing to hive. 
2) Other than the 2 workarounds I mentioned, is there any other option?

Thank you for your feedback in advance.

- Chen
Mime
View raw message