使用场景
有个hudi mor的事实表,需要与外部的维表进行关联以生成明细宽表,方案是基于flink sql对事实表进行增量查询,同时与外部的维表进行lookup join,除了无需编码之外,通过jdbc的方式连接外部表还能利用flink jdbc-connector的缓存功能。
这种join方式要求事实表必须有一个处理时间(process time)属性,所以在定义事实表时增加了一个计算列
create table if not exists ods_test_hudi (
`id` int,
`test` string,
`name` string,
`age` int,
`dt` string,
`create_date` timestamp(3),
`process_time` AS PROCTIME(), //增加计算列
PRIMARY KEY(`id`) NOT ENFORCED
)
WITH (
'connector'='hudi',
'table.type'='MERGE_ON_READ'
)
从flink sql的角度来看,这并没什么毛病,但是直接查这个表的数据时就会报错
tEnv.sqlQuery("select * from ods_test_hudi /*+ OPTIONS('read.start-commit'='earliest')*/").execute().print();
from ods_test_hudi /*+ OPTIONS('read.start-commit'='earlie