Upstash Kafka Setup
Create a Kafka cluster using Upstash Console or Upstash CLI by following Getting Started. Create two topics by following the creating topic steps. Let’s name first topicmaterialize_input
, since we are going to stream from this topic to Materialize
database. Name of the second topic can be materialize_output
. This one is
going to receive stream from Materialize.
Materialize Setup
Materialize iswire-compatible
with PostgreSQL, that’s why it can be used with
most of the SQL clients.
Sign up and complete activation of your
Materialize account first.
Once you completed your activation, you can sign in and enable the region to run
Materialize database. It can provide better performance if you enable the same
region with location of your Upstash Kafka cluster.
Region setup takes a few minutes. During that time, create a new app password
from Connect
tab for your project. This step will generate a password and
display it just once. You should copy that password to somewhere safe before it
disappears.
To interact with your Materialize database, you need to download one of the
PostgreSQL installers mentioned
here.
After installing a PostgreSQL on your machine, open SQL shell, run the command
appeared on Connect tab to connect SQL Shell to Materialize database. You will
need to enter the app password to log in.
Now you are connected to your Materialize!
Connect Materialize to Upstash Kafka
You first need to save Upstash username and password to Materialize’s secret management system to be able to connect Materialize to Upstash Kafka. To do this, run the following command from the psql terminal by replacing<upstash-username>
and <upstash-password>
with the username and password you
see on your Upstash Kafka cluster:
CREATE SECRET
command stores a sensitive value with the name assigned to it as
identifier. Once you define name and corresponding value with this command, you
will then be able to use the sensitive value by calling its name.
As the next step, we need to create a connection between Materialize and Upstash
Kafka by running following command from the psql terminal:
<connection-name>
is the going to be used as the name of the connection. You
can name it as you wish.
<upstash-endpoint>
is the endpoint of your Kafka. You can copy it from your
Upstash console.
Your connection is now established between Upstash Kafka and Materialize!
Create Source
Source means streaming from external data source or pipeline to Materialize database. By creating source, the message you add to the topic is going to be streamed from Upstash Kafka to Materialize source. You can create a source from SQL Shell first by running the following command:materialize_input
topic in your Kafka cluster.
Produce a message in this topic.

Create Sink
Sink means streaming from Materialize database to external data stores or pipelines. By creating a sink, the data you inserted to Materialize table or source will be streamed to the Upstash Kafka topic. For testing purposes, let’s create a new table. This table will be streamed to the Upstash Kafka sink topic.