未能在规格中找到答案。
所以,我想知道:我可以在蜂巢中做那样的事情吗?
insert into table my_table
with a as
(
select *
from ...
where ...
),
b as
(
select *
from ...
where ...
)
select
a.a,
a.b,
a.c,
b.a,
b.b,
b.c
from a join b on (a.a=b.a);
答案 0 :(得分:6)
在Hive版本0.13.0
中可用。 Usage documented here
答案 1 :(得分:2)
我猜你总是可以使用子查询:
insert into table my_table
select
a.a,
a.b,
a.c,
b.a,
b.b,
b.c
from
(
select *
from ...
where ...
) a
join
(
select *
from ...
where ...
) b
on a.a = b.a;
答案 2 :(得分:1)
Hadoop Hive WITH Clause Syntax and Examples
借助Hive WITH子句的帮助,您可以在同一查询构造中重复使用查询结果。您还可以使用WITH
子句改进Hadoop Hive查询。您可以通过将复杂,复杂的重复代码移动到WITH子句并引用在SELECT语句中创建的逻辑表来简化查询。
带有SELECT语句的蜂巢WITH子句示例
WITH t1 as (SELECT 1),
t2 as (SELECT 2),
t3 as (SELECT 3)
SELECT * from t1
UNION ALL
SELECT * from t2
UNION ALL
SELECT * from t3;
在INSERT语句中配置WITH子句 您可以在将数据插入表中时使用WITH子句。例如:
WITH t11 as (SELECT 10),
t12 as (SELECT 20),
t13 as (SELECT 3)
INSERT INTO t1
SELECT * from t11
UNION ALL
SELECT * from t12
UNION ALL
SELECT * from t13;