如何在使用concat时重命名列并在Hue-Impala中编写查询时创建管道分隔文件?

时间:2018-06-24 00:10:15

标签: sql impala hue

我正在写:

select concat(col1 , '|', col2 , '|', col3 , '|', col4 ,'|', col5)

我尝试使用AS获取列名,但出现错误。

concat(col1 as parent, '|', col2 as child, '|', .....)

输出也应具有单独的列名。我需要标题-应该是列名:

parent|child|date|year|month

1 个答案:

答案 0 :(得分:0)

大概,您想要这样的东西:

select str
from (select 'parent, child, . . . ' as str, 1 as ordering
      union all
      select concat(col1, '|', col2, '|', col3, '|', col4, ' |', col5) as str
      from t
     ) t
order by ordering;