Type Conversion Function
Syntax
CAST(value AS type)
Syntax Description
This function is used to forcibly convert types.
Precautions
If the input is NULL, NULL is returned.
Example
Convert amount into a character string. The specified length of the string is invalid after the conversion.
insert into temp select cast(amount as VARCHAR(10)) from source_stream;
| Example | Description |
|---|---|
| cast(v1 as varchar) | Converts v1 to a string. The value of v1 can be of the numeric type or of the timestamp, date, or time type. |
| cast (v1 as int) | Converts v1 to the int type. The value of v1 can be a number or a character. |
| cast(v1 as timestamp) | Converts v1 to the timestamp type. The value of v1 can be of the string, date, or time type. |
| cast(v1 as date) | Converts v1 to the date type. The value of v1 can be of the string or timestamp type. |
Flink jobs do not support the conversion of bigint to timestamp using CAST. You can convert it using to_timestamp or to_localtimestamp.
Last Article: Time Function
Next Article: Aggregate Function
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.