Get Started Free
course: ksqlDB 101

Hands On: Converting Data Formats with ksqlDB

2 min

Allison Walther

Integration Architect (Presenter)

Hands On: Converting Data Formats with ksqlDB

This exercise will teach you how to change data formats in ksqlDB.

Inspect Your Existing Data

  1. 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.

  2. Stop the query. Then expand a record to see the JSON structure.

Change Your Data's Format and Inspect It Again

  1. 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.

  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.

Use the promo code KSQLDB101 to get $25 of free Confluent Cloud usage

Be the first to get updates and new content

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.