In any KSQL query that will create a new Kafka topic, simply add the
PARTITIONS parameter to the
WITH clause. The new topic will now have that number of partitions.
1. Consider a Kafka topic called
clickstream-raw. We don’t even need to know how many partitions it has, but we do know we need a new topic that has five partitions.
2. Create a
STREAM from that partition:
CREATE STREAM clickstream-raw WITH (KAFKA_TOPIC=’clickstream-raw’,VALUE_FORMAT=’JSON’);
3. Create a new stream with the desired number of partitions. The newly created topic will be partitioned the way we specify.
CREATE STREAM clickstream_new WITH (PARTITIONS=5) AS SELECT * from clickstream_raw;