Click to copy

• Reviewed for ksqlDB 0.29

How to Find the Underlying Topic of a Table in ksqlDB

To know what’s the underlying topic of a table, use a DESCRIBE EXTENDED statement. Look for the first block that is printed, next to the Kafka topic label:

Name                 : SCORES_TABLE
Type                 : TABLE
Timestamp field      : Not set - using <ROWTIME>
Key format           : KAFKA
Value format         : JSON
Kafka topic          : scores_topic (partitions: 10, replication: 3)
Statement            : CREATE TABLE SCORES_TABLE (STUDENT_ID BIGINT PRIMARY KEY, NAME STRING, SCORE DOUBLE) WITH (KAFKA_TOPIC='scores_topic', KEY_FORMAT='KAFKA', PARTITIONS=10, VALUE_FORMAT='JSON');

In that case, the underlying Kafka topic is called scores_topic.

Tables always have an underlying topic

Regardless of whether the table is materialized or not, there will always be an underlying topic.

Materialized tables

Materialized tables will have an underlying topic that was created as a result of the materialization.

If you need to search for the root topic, you can find find the Statement label within the DESCRIBE EXTENDED statement output, and look at the stream or table that is used as a source. You can then describe t he stream or table you identified to find out more. Repeat these steps until you find the topic that you are looking for.

This is especially important when creating tombstone tables to delete rows from a table.

See all for all tables

Alternatively, you can also know about the underlying topics when listing all the tables in the cluster:

LIST TABLES;
Table Name              | Kafka Topic            | Key Format | Value Format | Windowed
-----------------------------------------------------------------------------------------
 ALICE_SCORE             | ALICE_SCORE            | KAFKA      | JSON         | false
 SCORES_EMPTY_TABLE      | scores_topic           | KAFKA      | JSON         | false
 SCORES_EMPTY_TABLE_MAT  | SCORES_EMPTY_TABLE_MAT | KAFKA      | JSON         | false
 SCORES_SOURCE_TABLE     | scores_topics          | KAFKA      | JSON         | false
 SCORES_TABLE_TOMBSTONES | scores_topic           | KAFKA      | KAFKA        | false
-----------------------------------------------------------------------------------------

Note the Kafka Topic column.

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