Skip to content

CREATE TYPE

Synopsis

1
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

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

Use the ADDRESS custom type in a statement:

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

Page last revised on: 2020-04-29


Last update: 2020-04-29