Bash/Hive: Adding a field to each rwo of a 2D array -


i running hive query through bash script.

out=$(hive -e "query here;") 

and result is:

val1 val2 

normally run following command add date:

echo "`eval date +%y%m%d`     $out" 

and result comes out as:

20150714 val1 val2 

however, when group by field, out 2d array expected:

g1  val1g1  val2g1 g2  val1g2  val2g2 g3  val1g3  val2g3 

however, need add date field each of rows now.

the previous command gives me following answer:

20150714    g1  val1g1  val2g1 g2  val1g2  val2g2 g3  val1g3  val2g3 

any easy way fix this?

unix_timestamp() work. wrap in from_unixtime make readable.

hive -e "select from_unixtime(unix_timestamp()) date, col1, col2 table;" 

Comments