Integration Architect (Presenter)
This exercise will demonstrate how to split streams in ksqlDB.
Begin by looking at the orders_combined stream from the module 9 exercise, which has orders from both the US and the UK:
SELECT * FROM orders_combined EMIT CHANGES;
Click Run query and see that the results contain orders from both the US and the UK.
Create a new stream to contain only orders from the US:
CREATE STREAM us_orders AS
SELECT * FROM orders_combined
WHERE source = 'US';
Click Run query.
Create another new stream to contain only orders from the UK:
CREATE STREAM uk_orders AS
SELECT * FROM orders_combined
WHERE source = 'UK';
Click Run query.
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.
Right now we're gonna work through how you would split streams. First, we'll start off by looking at an order's combined stream. This stream has orders from both the US and the UK. Go ahead and run that query. You'll see that the results, like I said, contain orders from both the US and the UK. Let's create a new stream called US orders. The purpose of this stream is to only have orders from the US. Run the query. Let's change that query to only have orders from the UK. Run that query. Now move over to the Flow tab. Go ahead and click on the US orders. On the right-hand side you'll see it only contains orders from the US. Click on the UK orders and you'll see it only has orders from the UK. And there you have it, you've split a stream.