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 >> how can I escape hive CLI output


Copy link to this message
-
how can I escape hive CLI output
Hi all:
I am new to hive, and I try to run a query through hive CLI and load the
result into mysql.
I try to redirect the CLI output to a tmp file and load the tmp file into
mysql table. The problem here is that some columns of our query result may
contains special chars, such as tab(\t), new line(\\), backslash (\) and so
on. The result in mysql table is corrupted by these chars because the CLI
output isn't escaped properly.
It seems what i want is mentioned in
hive-692<https://issues.apache.org/jira/browse/HIVE-692>,
but i can't find any solutions there.
A dirty way I think may be escaping the query result in HQL, such like:

regexp_replace(regexp_replace(regexp_replace(result_column_1, '\\\\',
'\\\\\\\\'), '\t', '\\\\t'), '\n', '\\\\n'),

I would like to know how to escape hive CLI output, or any alternative way
to accomplish such job.
Any help is appreciated.

Thanks.
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