Data types
Cloudera SQL Stream Builder (SSB) supports the Flink SQL data types. When SSB creates a table from a Kafka topic, it maps the JSON or Avro data of the topic to these types.
Data types describe the logical type of a value in a table, and the input and output types of operations. You can use the following Flink data types in SSB:
| Group | Data types |
|---|---|
| Character strings | CHAR, VARCHAR, STRING |
| Binary strings | BINARY, VARBINARY, BYTES |
| Boolean | BOOLEAN |
| Exact numerics | DECIMAL (fixed precision and scale), TINYINT,
SMALLINT, INTEGER (or INT),
BIGINT |
| Approximate numerics | FLOAT, DOUBLE |
| Date and time | DATE, TIME, TIMESTAMP,
TIMESTAMP_LTZ |
| Intervals | INTERVAL YEAR TO MONTH, INTERVAL DAY TO
SECOND |
| Constructed types | ARRAY, MAP, MULTISET,
ROW |
| Semi-structured | VARIANT |
| Other | RAW, BITMAP, structured
types |
How SSB maps Kafka data to Flink types
When you create a Kafka table with the wizard, SSB can detect the schema from a sample message in the topic. For more information, see Defining the schema of a Kafka table. SSB maps the values of a JSON message as follows:
| JSON value | Flink type |
|---|---|
| Object | ROW |
| Array | ARRAY of the type of its elements. An empty array becomes
ARRAY<STRING>. An array with elements of different types
becomes a union of those types. |
| String | STRING |
| Integer | BIGINT |
| Decimal number | DOUBLE |
Integer that does not fit in a BIGINT |
DECIMAL |
true or false |
BOOLEAN |
null |
STRING |
For Avro data, SSB converts the Avro schema with the Flink Avro type mapping. For the mapping, see Avro format in the Apache Flink documentation.
SSB makes every column of a detected schema nullable. When the table uses the Kafka record
timestamp as its event time, SSB adds an eventTimestamp column of type
TIMESTAMP_LTZ(3). For more information, see Using the default Kafka
timestamps.
For more information, see Flink SQL data types in the Apache Flink documentation.
