HIVe 查询组合 table

HIve query combined table

能否请您帮忙解决以下问题。

我有三个输入 table (Table1 , table 2 , table 3)

输出 table 应包含以下列

日期:(合并所有payment_date、receive_date、maturity_date), payment_amount(为给定的 payment_date 填充正确的数量), receive_amount(为给定的 receive_date 填充正确的数量), maturity_amount(为给定的 maturity_date 填充正确的数量), 总计 (payment_amount + receive_amount+ maturity_amount) 对于给定的日期列

Hive 支持 FULL JOIN,因此您可以使用:

select coalesce(t1.payment_date, t2.receiver_date, t3.maturity_date) as date,
       t1.payment_amount,
       t2.receive_amount,
       t3.maturity_amount
from table1 t1 full join
     table2 t2
     on t2.receive_date = t1.payment_date full join
     table3 t3
     on t3.maturity_date in (t2.receive_date, t1.payment_date)