visit
Note that Airbyte Cloud currently does not support Kafka as a destination, this is why we can only follow this demo with a self-hosted Airbyte instance.
Note that for Mac with M1, you might have some issues with the Airbyte due to the following issue:
So I would recommend using an Ubuntu VM to run the demo.
export DOCKER_BUILD_PLATFORM=linux/arm64
export DOCKER_BUILD_ARCH=arm64
export ALPINE_IMAGE=arm64v8/alpine:3.14
export POSTGRES_IMAGE=arm64v8/postgres:13-alpine
export JDK_VERSION=17
Start all services:
```bash
docker-compose up -d
Setup the Airbyte service by visiting your_server_ip:8000
and then follow the instructions.
Via the Airbyte UI, click on the Sources
tab and click on the Add new source
button.
orders
MySQL
your_server_ip
3306
shop
airbyte
password
CDC
Finally, click on the Setup source
button.
Start by clicking on the Destinations
tab and click on the Add new destination
button and fill in the following details:
redpanda
Kafka
Next, fill up all of the required fields and click on the Setup destination
button.
Topic
is orders
Bootstrap Servers
is redpanda:9092
Finally, click on the Save
button.
Click on the Connections
tab and click on the Add new connection
button and fill in the following details:
5 minutes
orders
and the 'Sync mode' to Incremental
Next click on the 'Setup connection' button. And finally, click on the Sync now
button to start the synchronization.
docker-compose exec redpanda bash
rpk topic list
rpk topic consume orders_topic
Note that if you've used a different topic name during the initial setup, you need to change it in the commands above.
If you don't see the topic yet, it would be possible that you might have to wait a few extra minutes and also make sure that the ordergen
service mock is up and running.
SOURCE
Next, we need to create a SOURCE
in Materialize.
mzcli
container:docker-compose run mzcli
Or if you have psql
installed:
psql -U materialize -h localhost -p 6875 materialize
Create a Kafka SOURCE
by executing the following statement:
CREATE SOURCE airbyte_source
FROM KAFKA BROKER 'redpanda:9092' TOPIC 'orders_topic'
FORMAT BYTES;
Note: change
orders_topic
to the topic you've specified during the Airbyte setup.
Use TAIL
to quickly see the data:
COPY (
TAIL (
SELECT
CAST(data->>'_airbyte_data' AS JSON) AS data
FROM (
SELECT CAST(data AS jsonb) AS data
FROM (
SELECT * FROM (
SELECT convert_from(data, 'utf8') AS data FROM airbyte_source
)
)
)
)
)
TO STDOUT;
You will see a stream of your data as Airbyte sends it to the destination and Materialize processes it with a very minimal, submillisecond delay.
For more information on how to use TAIL
, check out this blog post by :
Now that we have a SOURCE
in Materialize, we can create a materialized VIEW
. A materialized view, lets you retrieve incrementally updated results of your data using standard SQL queries very quickly.
CREATE MATERIALIZED VIEW airbyte_view AS
SELECT
data->>'id' AS id,
data->>'user_id' AS user_id,
data->>'order_status' AS order_status,
data->>'price' AS price,
data->>'created_at' AS created_at,
data->>'updated_at' AS updated_at
FROM (
SELECT
CAST(data->>'_airbyte_data' AS JSON) AS data
FROM (
SELECT CAST(data AS jsonb) AS data
FROM (
SELECT * FROM (
SELECT convert_from(data, 'utf8') AS data FROM airbyte_source
)
)
)
);
Next, run a query to see the data:
SELECT * FROM airbyte_view;
To visualize the data, you can use a BI tool like or alternatively, as Materialize is Postgres wire-compatible, you can use your favorite programming language and build your own dashboard. For more information on the supported tools and integrations, check out the
docker-compose down -v
Also Published