次のように、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 つのテーブルのデータを、上記の 2 つのテーブルとすべて同じフィールドを持つ 1 つの外部ハイブ テーブルにそのままマージしますが、どのデータがどのテーブルからのものかを識別するために 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';
どうすればできますか?