creating struct keys for sink streams

187 views
Skip to first unread message

larry Bilo

unread,
Feb 1, 2022, 7:24:05 PM2/1/22
to ksqldb-users
I'm new to this KsqlDB, so please bear with me. What I want to do is add a key-value pair to a STRUCT key.
My source topic has the following structure:
KEY = 0034e1b5-3f4a-4bf5-bc82-693e3363b451
VALUE = {
  "Branch": null,
  "Company Name": "testing2",
  "Email": "noe...@nomail.com",
  "Employee Code": null,
  "First Name": "first name",
  "Group(s)": "Portland",
  "Job Title": "simply great",
  "Last Name": "Last Name",
  "UserID": 64696,
  "Username": "John.Adams"
}How can I use something like CREATE STREAM AS statement to stream an enriched key that adds the UserID from the sources value to a structed key like the following?KEY = {"bv_Uid":64696, "bvUUID":"0034e1b5-3f4a-4bf5-bc82-693e3363b451"}
VALUE = {
  "Branch": null,
  "Company Name": "testing2",
  "Email": "noe...@nomail.com",
  "Employee Code": null,
  "First Name": "first name",
  "Group(s)": "Portland",
  "Job Title": "simply great",
  "Last Name": "Last Name",
  "UserID": 64696,
  "Username": "John.Adams"
}What's unclear to me is when using the create Stream AS statement how do I designate the KEY settings? (edited) 


Michael Drogalis

unread,
Feb 2, 2022, 6:13:19 PM2/2/22
to larry Bilo, ksqldb-users
Hey Larry, welcome to ksqlDB! Two useful tips.

1. Using the `PARTITION BY` (for a stream) or `GROUP BY` (for a table) clauses control what data is moved into the key. Whatever data you shuffle by automatically becomes the key.
2. You can use this guide to create and modify how struct columns hold data.

Hope this helps!

--
You received this message because you are subscribed to the Google Groups "ksqldb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ksql-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/ksql-users/e727b7b7-33be-470f-97f1-655bdc330509n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages