Click to copy

• Reviewed for ksqlDB 0.29

How to Union Two Tables in ksqlDB

The UNION operator is not supported in ksqlDB. However, there is a workaround for it.

Let’s say we have two tables, one with products for furniture and another for kitchen products. We want to merge those together into a new table of home products.

First, create a new table from querying the first table. We will use it as a base to union any additional table.

CREATE TABLE home_products_union
AS SELECT *
FROM furniture_products
EMIT CHANGES;

Then, insert into it the second table:

INSERT INTO home_products_union
SELECT *
FROM kitchen_products
EMIT CHANGES;

The result is a streaming table with the union of the previous two.

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