2

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\"}"

milo
  • 445
  • 5
  • 12
Amrit Jangid
  • 168
  • 1
  • 9

0 Answers0