Hi, Leonard

 我们的业务变得越来越复杂,所以现在需要 Join Hive 维表的情况非常普遍。现在维表分三种情况

 一,维表没有分区,没有 primary key

  这时候 `'streaming-source.partition.include' = 'latest',因为没有
parition,所以 latest 应该加载的就是全部的数据。

 二,维表有有分区,每个分区仅仅包含当天的数据,没有 primary key

  这种情况因为要 Join 全部的数据,所以还是需要设置 'streaming-source.partition.include' =
'all',但是还是因为没有 primary Key,所以无法 run。

三,维表有分区,每个分区包含全量数据,没有 primiary key

  这种情况可以设置,'streaming-source.partition.include' = 'latest',这个是是官网的案例,测试没有问题。


现在就是针对第二种情况,因为Hive的维度表不是我维护的,很多人都在用,所以不能修改去加上 primary key,无法进行 join.




--- BYW---

还有我看文档现在不支持 event time join, 官网的汇率是按照 process time
join,但是如果要回溯昨天的数据的时候,其实就会有问题。

我看 FLIP-132
<https://cwiki.apache.org/confluence/display/FLINK/FLIP-132+Temporal+Table+DDL+and+Temporal+Table+Join>
有提到 Event
Time semantics, 这是以后回支持的吗?



Leonard Xu <[email protected]> 于2021年2月10日周三 上午11:36写道:

> Hi,  macia
>
> > 在 2021年2月9日,10:40,macia kk <[email protected]> 写道:
> >
> > SELECT *FROM
> >    (
> >        SELECT  tt.*
> >        FROM
> >            input_tabe_01 tt
> >            FULL OUTER JOIN input_tabe_02 mt
> >            ON (mt.transaction_sn = tt.reference_id)
> >            and tt.create_time >= mt.create_time + INTERVAL '5' MINUTES
> >            and tt.create_time <= mt.create_time - INTERVAL '5' MINUTES
> >        WHERE COALESCE(tt.create_time, mt.create_time) is not NULL
> >    ) lt
> >    LEFT JOIN exchange_rate ex
> >    /*+
> OPTIONS('streaming-source.enable'='true','streaming-source.partition.include'
> > = 'all') */
> >    FOR SYSTEM_TIME AS OF lt.event_time ex ON DATE_FORMAT
> > (lt.event_time, 'yyyy-MM-dd') = cast(ex.date_id as String)
>
>
> 你说的异常我本地没有复现,异常栈能直接贴下吗?
>
> 另外看你写的是lt.event_time,
> 这个sql的是要做版本表的维表关联吗?目前Hive还不支持指定版本表的,只支持最新分区作为维表或者整个hive表作为维表,
> 两种维表的option你可参考下[1]
>
> 祝好,
> Leonard
> [1]
> https://ci.apache.org/projects/flink/flink-docs-master/dev/table/connectors/hive/hive_read_write.html#temporal-join-the-latest-table
>
>
>
>

回复