如何通过流读取Kafka主题的数据

发布于 2025-02-12 18:19:03 字数 411 浏览 1 评论 0原文

我想在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见你 2025-02-19 18:19:03

也许会回顾 101课程视频。

您可以print一个主题可以做一个基本的消费者,但是为了选择,您需要创建 a stream主题。

例如,使用(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 to SELECT, you need to CREATE a STREAM 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文