我正在尝试基于sourcetopic1和sourcetopic2在targettopic1中创建数据。两个源主题应该具有相同的事件结构。创建第一个目标流,然后尝试将数据从另一个源流插入当前流。有什么建议吗?
ksql> CREATE STREAM sourceTopic1Stream (category varchar, source varchar, type varchar, id varchar, payload varchar) WITH (KAFKA_TOPIC='sourceTopic1', VALUE_FORMAT='json');
Message
----------------
Stream created
----------------
ksql> CREATE STREAM sourceTopic2Stream (category varchar, source varchar, type varchar, id varchar, payload varchar) WITH (KAFKA_TOPIC='sourceTopic2', VALUE_FORMAT='json');
Message
----------------
Stream created
----------------
ksql> CREATE STREAM targetTopic1Stream WITH (kafka_topic='targetTopic1', partitions=3) AS select 'sourceTopic1' topicname, category, source, type, id, payload from sourceTopic1Stream where id like 'myid%';
Message
----------------------------
Stream created and running
----------------------------
ksql> INSERT INTO targetTopic1Stream SELECT 'sourceTopic2' topicname, category, source, type, id, payload FROM sourceTopic2Stream where id like 'myid%';
io.confluent.ksql.util.KsqlException: Sink topic TARGETTOPIC1STREAM does not exist in th e metastore.
ksql> show topics;
Kafka Topic | Registered | Partitions | Partition Replicas | Consumers | ConsumerGroups
------------------------------------------------------------------------------------------------
_confluent-metrics | false | 12 | 1 | 0 | 0
_schemas | false | 1 | 1 | 0 | 0
sourceTopic1 | true | 3 | 1 | 3 | 1
sourceTopic2 | true | 3 | 1 | 0 | 0
targetTopic1 | true | 3 | 1 | 0 | 0
------------------------------------------------------------------------------------------------
ksql> show streams;
Stream Name | Kafka Topic | Format
--------------------------------------------
SOURCETOPIC2STREAM | sourceTopic2 | JSON
TARGETTOPIC1STREAM | targetTopic1 | JSON
SOURCETOPIC1STREAM | sourceTopic1 | JSON
--------------------------------------------
ksql>
1条答案
按热度按时间qmelpv7a1#
这是ksql中的一个bug。我写在这里:https://github.com/confluentinc/ksql/issues/2123
解决方法是不指定
kafka_topic
在你的CREATE STREAM … AS
: