insert overwrite table erp.tsor_BKPF --要更新此表
SELECT td.* FROM (
select ta.*
from erp.tsor_BKPF ta --先要把原來中未更新的資料撈出來
leftjoin (select tc.MANDT,tc.BUKRS,tc.BELNR,tc.GJAHR from BI_SOR.TSOR_FN_R3_BKPF_D tc --此表為增量表
where tc.STATIS_DATE='${hivevar:statis_date}' )tb on
ta.MANDT=tb.MANDT
and ta.BUKRS=tb.BUKRS
and ta.BELNR=tb.BELNR
and ta.GJAHR=tb.GJAHR
where concat(tb.MANDT,tb.BUKRS,tb.BELNR,tb.GJAHR) isnull