How to change the below command so that i can export the output file as a pipe delimited file.
shellcommand='''hive -e 'set hive.cli.print.header=true; set hive.resultset.use.unique.column.names=false; use hivedb1; %s; ' | sed 's/[\t]/,/g' > %s '''%(selectqry,'path/outputfile.txt') 1 Answer
You can redirect the hive output with linux redirection. The standard output is resultset. You can concat the output columns with concat_ws function. Like:
CMD=`hive -e "set hive.cli.print.header=true; set hive.resultset.use.unique.column.names=false; use hivedb1; select concat_ws('|',col_1,col_2,col_3) from tbl" 1> output_file.txt 2> log.txt` 1