Integration Architect (Presenter)
This exercise will teach you how to change data formats in ksqlDB.
Begin by printing your orders_flat stream from Hands On: Flatten Nested Records with ksqlDB to show the existing JSON data:
PRINT orders_flat FROM BEGINNING;
Click Run query.
Stop the query. Then expand a record to see the JSON structure.
Enter a CREATE STREAM AS statement, with VALUE_FORMAT set to delimited:
CREATE STREAM orders_csv
WITH(VALUE_FORMAT='delimited', KAFKA_TOPIC='orders_csv') AS
SELECT * FROM orders_flat EMIT CHANGES;
Click Run query. This will help to clean up the JSON you saw in Step 2.
Run a PRINT statement to see your newly delimited data:
PRINT orders_csv FROM BEGINNING;
Click Run query, then scroll down and expand a record to see the comma-delimited fields.
It's as easy as that: VALUE_FORMAT helps you to change formats within ksqlDB.
In this exercise, we'll work with changing data formats. The first thing that we're gonna want to do is print out this orders_flat stream to show the existing JSON data. KsqlDB formats it pretty poorly. Let's expand a record to see the JSON structure. Go ahead and enter a create stream as statement with the value format specified to delimit it. This will help clean up that JSON structure we saw earlier. Run the query. Now let's run a print orders_CSV statement to show our newly delimited data. Again, scroll down and expand a record to show the comma-delimited fields. And it's as easy as that. Value format helps you change between different formats within ksqlDB.
We will only share developer content and updates, including notifications when new content is added. We will never send you sales emails. 🙂 By subscribing, you understand we will process your personal information in accordance with our Privacy Statement.