我有 2 个外部配置单元表,如下所示。我已经使用 sqoop 从 oracle 中填充了数据。
create external table transaction_usa
(
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
)
row format delimited
stored as textfile
location '/user/stg/bank_stg/tran_usa';
create external table transaction_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
)
row format delimited
stored as textfile
location '/user/stg/bank_stg/tran_canada';
现在我想合并以上 2 个表数据,因为它在 1 个外部配置单元表中,其所有字段与上述 2 个表中的所有字段相同,但有 1 个额外列来标识哪些数据来自哪个表。具有附加列的新外部表为source_table
. 新的外部表如下。
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';
我该怎么做。?