Click to copy

• Reviewed for ksqlDB 0.29

How to Know if a Table is Materialized in ksqlDB

A materialized table has an associated persistent query that keeps it up-to-date with any new changes from the sources. On the other hand, a non-materialized table is just metadata on top of a physical topic.

The easiest way to see if a table is materialized is by looking at its DESCRIBE EXTENDED statement:

DESCRIBE table_name EXTENDED;

There are a few hints that will tell you whether i t is materialized.

First, try looking for the persistent query. The name of the query starts with CTAS and can be found under the section that tells who is writing to this table.

Queries that write from this TABLE
-----------------------------------
CTAS_SCORES_EMPTY_TABLE_MAT_123 (RUNNING) : 
  CREATE TABLE SCORES_EMPTY_TABLE_MAT 
  WITH (KAFKA_TOPIC='SCORES_EMPTY_TABLE_MAT', PARTITIONS=10, REPLICAS=3) 
  AS SELECT * 
  FROM SCORES_EMPTY_TABLE SCORES_EMPTY_TABLE 
  EMIT CHANGES;

If you haven’t found the persistent query, another hint about the state of the materialization is to look at the consumer groups summary that only appears for materialized tables:

Consumer Groups summary:
Consumer Group       : _confluent-ksql-ksql-serverquery_CTAS_SCORES_EMPTY_TABLE_MAT_123
Kafka topic          : scores_topic
Max lag              : 0
 Partition | Start Offset | End Offset | Offset | Lag
------------------------------------------------------
 0         | 0            | 2          | 2      | 0
 1         | 0            | 0          | 0      | 0
 2         | 0            | 0          | 0      | 0
 3         | 0            | 0          | 0      | 0
 4         | 0            | 1          | 1      | 0
 5         | 0            | 0          | 0      | 0
 6         | 0            | 0          | 0      | 0
 7         | 0            | 0          | 0      | 0
 8         | 0            | 0          | 0      | 0
 9         | 0            | 0          | 0      | 0
------------------------------------------------------
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