1

我们有一个查询,用于使用INSERT-SELECT直接在另一个表上的查询将数据加载到表中,如下所示

INSERT OVERWRITE TABLE <table1>
SELECT * FROM <table2> t2
WHERE <some-conditions>;

同样,如何加载具有复杂数据类型的表?如何让我的 SELECT 查询中的几个/一些列为复杂的数据类型列做出贡献?我清楚了吗?

table1 的架构是

TABLE (col1 INT, col2 STRING, col3 ARRAY<STRING>)

注意:从文件加载到此类表是可能的,但我只想尝试是否可以使用上述INSERT-SELECT查询方式加载。感谢您的兴趣。

4

1 回答 1

0

与 insert .. select 等效的 Hive 是以下之一:

1. from (table 2 query)
insert [overwrite] table <table1> [partition clause if partitioned table]

或者

2. create table table1 as select <table2 query>

请注意#2 (CTAS) 不可靠。将 #1 与显式表创建或类似的东西结合使用会更好地为您服务:

create table <table1> **like** table2
于 2013-12-01T19:20:17.437 回答