CREATE TYPE statement in ksqlDB for Confluent Platform

Synopsis

CREATE TYPE <type_name> AS <type>;

Description

Create an alias for a complex type declaration.

The CREATE TYPE statement registers a type alias directly in KSQL. Any types registered by using this command can be leveraged in future statements. The CREATE TYPE statement works in interactive and headless modes.

Any attempt to register the same type twice, without a corresponding DROP TYPE statement, will fail.

Example

CREATE TYPE ADDRESS AS STRUCT<number INTEGER, street VARCHAR, city VARCHAR>;

Use the ADDRESS custom type in a statement:

CREATE TYPE PERSON AS STRUCT<name VARCHAR, address ADDRESS>;