I want to write hql that concatenates all columns in a table with comma separated.
Execute SELECT query
SELECT COL1 ,COL2 ,COL3 ,COL4 ,CONCAT???(T1.*) AS CONCAT_COL -- SQL for Concatenates all columns FROM target_table AS T1
Is there anyone has good idea for this ??
I'm not sure what your original goal is - the following approach may help; or possibly not...
Beeline has some output format features which enables it to output the resultset in csv/tsv2 format. see: https://community.hortonworks.com/questions/25789/how-to-dump-the-output-from-beeline.html?childToVi...
I think with `concat_ws` you are very close; but I'm afraid its not possible to convert a struct into an array (or at least into a map - in which case you might be able to use `map_values` to obtain the array)
You need to use CONCAT_WS (separator,col1,col2,...colX) :
select CONCAT_WS ('',c12,c13,c14,c15,c16) FROM your_table;,
Use CONCAT_WS , where you give the separator as 1st term and then the list of columns to concat :
select CONCAT_WS (' ',c12,c13,c14,c15,c16) from your_table) ;