我有一个hive查询,如下所示:
set hive.cli.print.header=true;
select x1, x2, x3 from table1
union all
select x1, x2, x3 from table2
问题是,hive会自动为列名添加新的表名,因此结果中的列名如下所示:
_u1.x1 _u1.x2 _u1.x3
我不想要“_u1”。如何将列名保持为:
x1 x2 x3
答案 0 :(得分:-1)
select x1, x2, x3 from
(select x1, x2, x3 from table1
union all
select x1, x2, x3 from table2) as test;
<强> 之前: 强>
select order_id,order_date from orders limit 1
union all
select order_id,order_date from orders limit 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_u1.order_id _u1.order_date
1 2013-07-25 00:00:00.0
1 2013-07-25 00:00:00.0
<强> 后: 强>
select order_id, order_date from
(select order_id,order_date from orders limit 1
union all
select order_id,order_date from orders limit 1) as test;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
order_id order_date
1 2013-07-25 00:00:00.0
1 2013-07-25 00:00:00.0