如何通过流读取Kafka主题的数据
我想在kafka中创建my_stream
,该从my_topic
读取数据消息,然后将其推到另一个target_topic
。使用KSQL语句:
使用(KAFKA_TOPIC ='target_topic')创建流MY_STREAM,作为从my_topic;
select * select * select;
结果到错误my_topic不存在
。显然,无法使用读取my_topic
的访问来创建流。流只能从另一个流读取。有没有办法使my_stream从my_topic读取数据?
PS稍后附加:
不管是如何创建流,无论是“选择”,它是否是通过主题推出和从流中提取数据创建的。
I would like to create MY_STREAM
in Kafka that reads the data messages from MY_TOPIC
and push it to another TARGET_TOPIC
. Using KSQL statement:
CREATE STREAM MY_STREAM WITH (KAFKA_TOPIC='TARGET_TOPIC') AS SELECT * FROM MY_TOPIC;
results to an error MY_TOPIC doesn't exist
. Apparently Stream cannot be created with read access to MY_TOPIC
. Stream can only read from another Stream. Is there a way to make MY_STREAM to read data from MY_TOPIC?
P.S. Appended later:
Regardless on how Stream was created, with "as select" or not it is created with Topic pushing and pulling data from Stream.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许会回顾 101课程视频。
您可以
print
一个主题可以做一个基本的消费者,但是为了选择
,您需要创建
astream
主题。例如,
使用(kafka_topic ='my_topic',value_format =“ ...”)
create stream my_stream(fields ...)create
创建流...作为选择 *
,没有任何过滤器/分组/计算,因为它们将是完全相同的流。此用例应仅限于类型的转换和重新分配主题,这听起来不像您在做。Perhaps review the 101 Course videos.
You can
PRINT
a topic to do a basic consumer, but in order toSELECT
, you need toCREATE
aSTREAM
over the topic.For example,
CREATE STREAM MY_STREAM (fields...) WITH (kafka_topic='MY_TOPIC', value_format="...")
Also, it is redundant to do
CREATE STREAM ... AS SELECT *
without any filter/grouping/calculations since those would be the exact same stream. This use-case should be limited to type-conversions and re-partitioning of topics, which doesn't sound like you're doing.