CCAAK practice question 12 of 15

Which ksqlDB statement produces data that is persisted into a Kafka topic?

Full set: 54 questions
Answer options
A: SELECT (Pull Query)
B: SELECT (Push Query)
C: INSERT VALUES Correct answer
D: CREATE TABLE
Correct Answer:
C. INSERT VALUES
Explanation

The INSERT INTO ... VALUES statement is a Data Manipulation Language (DML) command in ksqlDB used to produce a single row of data into an existing stream. Since every ksqlDB stream is backed by a Kafka topic, executing this statement directly results in a new message being produced and durably persisted to that underlying topic. This is the primary method for inserting individual, ad-hoc records into a stream from the ksqlDB CLI or an application.

Why Incorrect

A. SELECT (Pull Query): This query retrieves the current state from a materialized table at a specific point in time. It reads data; it does not write new data to a topic.
B. SELECT (Push Query): This is a continuous query that streams results to the client as new events arrive. It does not, by itself, persist its output to a new Kafka topic.
D. CREATE TABLE: This is a Data Definition Language (DDL) statement that defines the schema and properties of a table. It sets up structure but does not insert data records.

References

1. Confluent Documentation, ksqlDB SQL Reference, INSERT INTO: "Use the INSERT INTO statement to insert a row into an existing stream. The inserted row is published to the underlying Kafka topic of the stream."

Source: Confluent, Inc. (2023). ksqlDB Documentation: INSERT INTO. Retrieved from https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/insert-into/

2. Confluent Documentation, ksqlDB Concepts, Queries: "ksqlDB supports two types of queries: pull queries and push queries... A pull query is a SELECT query that fetches a result and terminates... A push query is a SELECT query that emits a continuous stream of updates."

Source: Confluent, Inc. (2023). ksqlDB Documentation: Queries. Retrieved from https://docs.ksqldb.io/en/latest/concepts/queries/

3. Confluent Documentation, ksqlDB SQL Reference, CREATE TABLE: "Use the CREATE TABLE statement to create a new table from an existing Kafka topic, or to create a new table and a corresponding new Kafka topic." (Note: This describes the creation of the structure, not the insertion of data rows).

Source: Confluent, Inc. (2023). ksqlDB Documentation: CREATE TABLE. Retrieved from https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/create-table/

Scroll to Top