Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache kafka 加入卡夫卡KSQL(0.12.0)_Apache Kafka_Ksqldb - Fatal编程技术网

Apache kafka 加入卡夫卡KSQL(0.12.0)

Apache kafka 加入卡夫卡KSQL(0.12.0),apache-kafka,ksqldb,Apache Kafka,Ksqldb,我正在使用KSQL版本0.12.0,无法理解连接。我来自坚实的关系基础(Postgres、Oracle、MySQL),最近开始使用Kafka,特别是KSQL 我创建了下面的表和流,因为我的目标是理解KSQL,在我的示例中,我想连接3个表,它们有一个共同的列(ID)。结果不是我所理解的JOIN,我希望你们中的任何一位能够解释我所理解的缺失 create table fornecedores(id int primary key, name varchar) with( kafka_topic

我正在使用KSQL版本0.12.0,无法理解连接。我来自坚实的关系基础(Postgres、Oracle、MySQL),最近开始使用Kafka,特别是KSQL

我创建了下面的表和流,因为我的目标是理解KSQL,在我的示例中,我想连接3个表,它们有一个共同的列(ID)。结果不是我所理解的JOIN,我希望你们中的任何一位能够解释我所理解的缺失

create table fornecedores(id int primary key, name varchar) 
with(
  kafka_topic='fornecedores', 
  value_format='JSON', 
  partitions=1, 
  replicas=1
);
insert into fornecedores(id,name) values(1,'marcia');


create table racas(id int primary key, name varchar) 
with(
   kafka_topic='racas', 
   value_format='JSON', 
   partitions=1, 
   replicas=1
);
insert into racas(id,name) values(1,'duroc');
insert into racas(id,name) values(2,'landrace');


create table tipos(id int primary key, name varchar) 
with(
   kafka_topic='tipos', 
   value_format='JSON', 
   partitions=1, 
   replicas=1
);
insert into tipos(id,name) values(1,'suinos');
insert into tipos(id,name) values(2,'bovinos');


create stream eventos(id int key, raca_id int, fornecedor_id int, tipo_id int)
with(
   kafka_topic='eventos', 
   value_format='JSON', 
   partitions=1, 
   replicas=1
);
insert into eventos(id, raca_id, fornecedor_id, tipo_id) values(1, 1, 1, 1);
insert into eventos(id, raca_id, fornecedor_id, tipo_id) values(2, 2, 1, 1);
insert into eventos(id, raca_id, fornecedor_id, tipo_id) values(3, 1, 1, 2);



create stream eventos_racas 
as 
  select id, raca_id from eventos partition by raca_id;

create stream eventos_racas_raw 
as 
  select e.id as id, e.raca_id as raca_id, x.name as name 
  from eventos_racas e 
  inner join racas x on e.raca_id = x.id 
  partition by e.id;

create table eventos_racas_tbl(id int primary key, raca_id int, name varchar)
with(
   kafka_topic='EVENTOS_RACAS_RAW', 
   value_format='JSON'
);


create stream eventos_fornecedores 
as 
  select id, fornecedor_id 
  from eventos 
  partition by fornecedor_id;

create stream eventos_fornecedores_raw 
as 
  select e.id as id, e.fornecedor_id as fornecedor_id, x.name as name 
  from eventos_fornecedores e 
  inner join fornecedores x on e.fornecedor_id = x.id 
  partition by e.id;

create table eventos_fornecedores_tbl(id int primary key, fornecedor_id int, name varchar)
with(
  kafka_topic='EVENTOS_FORNECEDORES_RAW', 
  value_format='JSON'
);


create stream eventos_tipos 
as 
  select id, tipo_id 
  from eventos 
  partition by tipo_id;

create stream eventos_tipos_raw 
as 
  select e.id as id, e.tipo_id as tipo_id, x.name as name 
  from eventos_tipos e 
  inner join tipos x on e.tipo_id = x.id 
  partition by e.id;

create table eventos_tipos_tbl(id int primary key, tipo_id int, name varchar)
with(
   kafka_topic='EVENTOS_TIPOS_RAW', 
   value_format='JSON'
);


Finally the last select to join all 3 tables;


select * 
from eventos_racas_tbl e 
inner join eventos_fornecedores_tbl x on e.id = x.id 
inner join eventos_tipos_tbl y on e.id = y.id 
emit changes;


but the result seems to me more like a UNION than a JOIN.
你们谁能帮我理解