0

我是新来的蜂巢。我创建了 2 个外部配置单元表,并使用 sqoop 从 oracle 导入数据。我还创建了一个新的外部表,其中包含External table 1 and External table 2以下两个数据

create external table transaction_usa_canada
(
tran_id int,
acct_id int,
tran_date string,
amount double,
description string,
branch_code string,
tran_state string,
tran_city string,
speendby string,
tran_zip int,
source_table string
)
row format delimited
stored as textfile
location '/user/gds/bank_ds/tran_usa_canada';

现在,我不知道如何将 2 个外部表的数据合并到上面的外部表中。

请帮忙。

4

2 回答 2

0

您可以使用联合语句将它们读入新表。

    INSERT OVERWRITE TABLE [database].[table]
SELECT 
* 
FROM (
SELECT 
Col_1 STRING,
Col_2 STRING,
Col_3 STRING
FROM
[table]
UNION ALL
SELECT
Col_1 STRING,
Col_2 STRING,
Col_3 STRING
FROM 
[table]) [table];
于 2016-05-18T18:50:08.483 回答
0

如果您的 2 个外部表具有相同的列结构,则可以将文本文件复制到一个公共位置或文件夹并创建一个指向新位置的新表。

如果 2 个外部表的元数据不同,您可以考虑将“create table as select”选项加载到新表。

于 2016-05-18T12:10:30.480 回答