CREATE TABLE AS SELECT¶
1 2 3 4 5 6 7 8 9 10
Create a new ksqlDB table along with the corresponding Kafka topic and
stream the result of the SELECT query as a changelog into the topic.
Note that the WINDOW clause can only be used if the
from_item is a
For joins, the key of the resulting table will be the value from the column from the left table that was used in the join criteria. This column will be registered as the key of the resulting table if included in the selected columns.
For joins, the columns used in the join criteria must be the keys of the tables being joined.
For more information, see Join Event Streams with ksqlDB.
The WITH clause supports the following properties:
|KAFKA_TOPIC||The name of the Kafka topic that backs this table. If this property is not set, then the name of the table will be used as default.|
|VALUE_FORMAT||Specifies the serialization format of the message value in the topic. Supported formats:
|VALUE_DELIMITER||Used when VALUE_FORMAT='DELIMITED'. Supports single character to be a delimiter, defaults to ','. For space and tab delimited values you must use the special values 'SPACE' or 'TAB', not an actual space or tab character.|
|PARTITIONS||The number of partitions in the backing topic. If this property is not set, then the number of partitions of the input stream/table will be used. In join queries, the property values are taken from the left-side stream or table.|
|REPLICAS||The replication factor for the topic. If this property is not set, then the number of replicas of the input stream or table will be used. In join queries, the property values are taken from the left-side stream or table.|
|TIMESTAMP||Sets a field within this tables's schema to be used as the default source of
Note: This doesn't affect the processing of the query that populates this table. For example, given the following statement:
CREATE TABLE foo WITH (TIMESTAMP='t2') ASThe window into which each row of
|TIMESTAMP_FORMAT||Used in conjunction with TIMESTAMP. If not set will assume that the timestamp field is a
|WRAP_SINGLE_VALUE||Controls how values are serialized where the values schema contains only a single field. The setting controls how the query will serialize values with a single-field schema.
If set to
If set to
If not supplied, the system default, defined by ksql.persistence.wrap.single.values and defaulting to
Note: Supplying this property for formats that do not support wrapping, for example
- To use Avro or Protobuf, you must have Schema Registry enabled and
ksql.schema.registry.urlmust be set in the ksqlDB server configuration file. See Configure ksqlDB for Avro or Protobuf.
- Avro and Protobuf field names are not case sensitive in ksqlDB. This matches the ksqlDB column name behavior.