Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> Question on escaped characters in Hive Shell


Copy link to this message
-
Question on escaped characters in Hive Shell
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
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB