flinksql 实时查询hudi 的数据

1.版本

组件版本
hudi10.0
flink13.5

2. 场景:

在flink 中新建一张表(t1)插入数据, 然后同时用过另外一张表进行查询(t2) 

场景如图

在这里插入图片描述

3. t1 建表

	CREATE TABLE t1(
	  uuid VARCHAR(20), 
	  name VARCHAR(10),
	  age INT,
	  ts TIMESTAMP(3),
	  `partition` VARCHAR(20)
	)
	PARTITIONED BY (`partition`)
	WITH (
	  'connector' = 'hudi',
	  'path' = 'hdfs://192.168.1.161:8020/hudi-warehouse/hudi-t1',
	  'write.tasks' = '1',
	  'compaction.tasks' = '1', 
	  'table.type' = 'MERGE_ON_READ'
	);

3.1 插入数据

INSERT INTO t1 VALUES('id1','Danny',28,TIMESTAMP '1970-01-01 00:00:01','par1');
insert into t1 values ('id9','Danny',18,TIMESTAMP'1970-01-01 00:00:01','par9');
INSERT INTO t1 VALUES
('id2','Stephen',33,TIMESTAMP '1970-01-01 00:00:02','par1'),
('id3','Julian',53,TIMESTAMP '1970-01-01 00:00:03','par2'),
('id4','Fabian',31,TIMESTAMP '1970-01-01 00:00:04','par2'),
('id5','Sophia',18,TIMESTAMP '1970-01-01 00:00:05','par3'),
('id6','Emma',20,TIMESTAMP '1970-01-01 00:00:06','par3'),
('id7','Bob',44,TIMESTAMP '1970-01-01 00:00:07','par4'),
('id8','Han',56,TIMESTAMP '1970-01-01 00:00:08','par4');


4.另外开一个窗口创建表t2

CREATE TABLE t2(
uuid VARCHAR(20), 
name VARCHAR(10),
age INT,
ts TIMESTAMP(3),
`partition` VARCHAR(20)
)
PARTITIONED BY (`partition`)
WITH (
'connector' = 'hudi',
'path' = 'hdfs://192.168.1.161:8020/hudi-warehouse/hudi-t1',
'table.type' = 'MERGE_ON_READ',
'read.tasks' = '1', 
'read.streaming.enabled' = 'true',  -- this option enable the streaming read
'read.streaming.start-commit' = '20210316134557',  -- specifies the start commit instant time
'read.streaming.check-interval' = '4'   -- specifies the check interval for finding new source commits, default 60s.
);

5. 在t1 表插入数据 在t2表中会实时增加

在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值