简体   繁体   中英

using existing kafka topic with avro in ksqldb

suppose i have a topic, lets say 'some_topic'. data in this topic is serialized with avro using schema registry. schema subject name is the same as the name of the topic - 'some_topic', without '-value' postfix

what i want to do is to create a new topic, lets say 'some_topic_new', where data will be serialized with the same schema, but some fields will be 'nullified'

i'm trying to evaluate if this could be done using ksqldb and have two questions:

  1. is it possible to create stream/table based on existing topic and using existing schema? maybe something like create table some_topic (*) with (schema_subject=some_topic, ...) . so fields for new table would be taken from existing schema automatically

  2. could creating of new schema with '-value' postfix be avoided when creating new stream/table?

When you create a stream in ksqlDB based on another you can have it inherit the schema. Note that it won't share the same schema though, but the definition will be the same.

CREATE STREAM my_stream 
    WITH (KAFKA_TOPIC='some_topic', VALUE_FORMAT='AVRO');

CREATE STREAM my_stream_new 
    WITH (KAFKA_TOPIC='some_topic_new', VALUE_FORMAT='AVRO') AS 
    SELECT * FROM my_stream;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM