mysql 的建表语句
use test;
create table base (
        id int primary key,
        location varchar(20)
);
create table stuff(
        id int primary key,
        b_id int,
        name varchar(20)
);

flink sql client 的建表语句
create table base (
        id int primary key,
        location varchar(20)
)WITH (
   'connector' = 'kafka',
   'topic' = 'example',
   'properties.group.id' = 'testGroup',
   'scan.startup.mode' = 'latest-offset',
   'properties.bootstrap.servers' = 'localhost:9092',
   'format' = 'canal-json'
);
create table stuff(
        id int primary key,
        b_id int,
        name varchar(20)
)WITH (
   'connector' = 'kafka',
   'topic' = 'example',
   'properties.group.id' = 'testGroup',
   'scan.startup.mode' = 'latest-offset',
   'properties.bootstrap.servers' = 'localhost:9092',
   'format' = 'canal-json'
);

flink 查询语句
select distinct stuff.id s_id, base.id b_id, base.location, stuff.name
from stuff inner join base
on stuff.b_id = base.id;

mysql 插入语句
insert into base values (1, 'beijing');
insert into stuff values (1, 1, 'zz');

flink 结果
<http://apache-flink.147419.n8.nabble.com/file/t858/2020-08-13_15-12-36_%E7%9A%84%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png>
 

mysql 执行同样的查询的结果:
+------+------+----------+------+
| s_id | b_id | location | name |
+------+------+----------+------+
|    1 |    1 | beijing  | zz   |
+------+------+----------+------+
1 row in set (0.01 sec)


而且有时候连结果正确的行都不会出现,只会出现含 null 的行。

求助大家。。。





--
Sent from: http://apache-flink.147419.n8.nabble.com/

回复