ksqlDB get message's value as string column from Json topic

Viewed 98

There is a topic, containing plain JSON messages, trying to create a new stream by extracting few columns from JSON and another column as varchar with the message's value.

Here is a sample message in a topic_json

{
  "db": "mydb",
  "collection": "collection",
  "op": "update"
}

Creating a stream like -

CREATE STREAM test1 (
    db VARCHAR,
    collection VARCHAR
VAL STRING
  ) WITH (
    KAFKA_TOPIC = 'topic_json',
    VALUE_FORMAT = 'JSON'
  );

Output of this stream will contain only db and collection columns, How can I add another column as message's value - "{\"db\":\"mydb\",\"collection\":\"collection\",\"op\":\"update\"}"

0 Answers
Related