Click to copy

• Reviewed for ksqlDB 0.29

How to Insert Struct Values in ksqlDB

Use the STRUCT() function to create new struct values :

INSERT INTO scores_stream(
  score, 
  user
) VALUES (
  3.8, 
  STRUCT(name := 'Alice', age := 30)
);

For reference, the scores_stream was created with the statement below:

CREATE STREAM scores_stream (
  score DOUBLE,
  user STRUCT<name STRING, age INT>
) WITH (
  KAFKA_TOPIC = 'scores_topic',
  VALUE_FORMAT = 'JSON',
  PARTITIONS = 10
);
Remember that y ou can nest STRUCT() calls to create nested structures.
Discover what readers are saying
topictale
Get easy to digest how-tos on ksqlDB
Sign up
Please read our Privacy Policy to understand how we protect and manage your data.
You may also like