非相等配置单元查询的解决方法

3okqufwl  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(326)

我试图重写Hive上的follow查询

select 
    TFCT_CHARGE.SUBS_KEY, 
    TFCT_CHARGE.PRODUCT_KEY, 
    TFCT_CHARGE.CHARGE_NVAL, 
    TFCT_CHARGE.B_SUBS_KEY, 
    TFCT_CHARGE.DELETE_DT, 
    HFCT_SUBS_SEGMENT.SEGMENT_KEY, 
    TFCT_CHARGE.EVENT_DT, 
    TFCT_CHARGE.DWH_SRC_TABLE_KEY
  from
TFCT_CHARGE LEFT OUTER JOIN HFCT_SUBS_SEGMENT
ON (
TFCT_CHARGE.B_SUBS_KEY = HFCT_SUBS_SEGMENT.SUBS_KEY and
TFCT_CHARGE.EVENT_DT >= HFCT_SUBS_SEGMENT.EFF_DT    and
TFCT_CHARGE.EVENT_DT < HFCT_SUBS_SEGMENT.EXP_DT     and
HFCT_SUBS_SEGMENT.SEGMENT_TYPE_KEY = 1)

但也有不平等的质疑。有人能给我一些解决办法吗?tnx!

yrdbyhpb

yrdbyhpb1#

要模拟非等距左外联接,请执行以下操作:
创建左表的副本,并添加序列行号
进行内部连接:
按序列左连接:
请参阅我的答案这里的代码:配置单元:工作为非等左连接

l7mqbcuq

l7mqbcuq2#

很简单)

select 
    TFCT_CHARGE.SUBS_KEY, 
    TFCT_CHARGE.PRODUCT_KEY, 
    TFCT_CHARGE.CHARGE_NVAL, 
    TFCT_CHARGE.B_SUBS_KEY, 
    TFCT_CHARGE.DELETE_DT, 
    HFCT_SUBS_SEGMENT.SEGMENT_KEY, 
    TFCT_CHARGE.EVENT_DT, 
    TFCT_CHARGE.DWH_SRC_TABLE_KEY
  from
TFCT_CHARGE INNER JOIN HFCT_SUBS_SEGMENT
ON (
TFCT_CHARGE.B_SUBS_KEY = HFCT_SUBS_SEGMENT.SUBS_KEY
HFCT_SUBS_SEGMENT.SEGMENT_TYPE_KEY = 1)
where
TFCT_CHARGE.EVENT_DT >= HFCT_SUBS_SEGMENT.EFF_DT    and
TFCT_CHARGE.EVENT_DT < HFCT_SUBS_SEGMENT.EXP_DT     and

相关问题