问题遇到的现象和发生背景 :
软件版本:flink-1.15.1,kafka-2.12-2.81,OGG-19.1.0.0
最终目的:创建 flink 的 kafka 源表,解析 ogg-json 数据。
这是kafka中的数据,是ogg写入的json:
{"table":"OGG.TEST_ORDER","op_type":"I","op_ts":"2022-08-26 11:30:55.996844","current_ts":"2022-08-26 11:31:03.001000","pos":"00000000010000446271","primary_keys":["O_ID"],"before":null,"after":{"O_ID":"JD20220826001444","DT":"2022-08-26 11:30:56.710697000","U_ID":1.4000008E7,"P_ID":"A3702","QUANTITY":5.0,"PAY_ID":"A"}}
{"table":"OGG.TEST_ORDER","op_type":"I","op_ts":"2022-08-26 11:31:00.995329","current_ts":"2022-08-26 11:31:08.009000","pos":"00000000010000446483","primary_keys":["O_ID"],"before":null,"after":{"O_ID":"JD20220826001445","DT":"2022-08-26 11:31:01.439758000","U_ID":1.4000009E7,"P_ID":"A3703","QUANTITY":9.0,"PAY_ID":"B"}}
{"table":"OGG.TEST_ORDER","op_type":"I","op_ts":"2022-08-26 11:31:03.000370","current_ts":"2022-08-26 11:31:10.012000","pos":"00000000010000446696","primary_keys":["O_ID"],"before":null,"after":{"O_ID":"JD20220826001446","DT":"2022-08-26 11:31:03.931785000","U_ID":1.400001E7,"P_ID":"A3705","QUANTITY":9.0,"PAY_ID":"C"}}
问题相关代码,请勿粘贴截图 :
在flink的sql-client执行以下语句:
create table test_order
(
o_id varchar(20),
dt timestamp,
u_id int,
p_id varchar(20),
quantity int,
pay_id varchar(20)
) with (
'connector' = 'kafka',
'topic' = 'test_order',
'properties.bootstrap.servers' = '192.168.137.4:9092',
'properties.group.id' = 'testGroupFlink',
'format' = 'ogg-json',
'scan.startup.mode' = 'latest-offset'
);
select * from test_order;
运行结果及报错内容 :
显示全是null,这是为什么?
我的解答思路和尝试过的方法
尝试更换过 flink/lib 下的 flink-json-1.15.1.jar 为 flink-json-1.15.0.jar 或 flink-json-1.15.2.jar 也不行。
我想要达到的结果:
我想成功解析出数据,就像这样: