VeloDB Cloud
SQL Manual
Functions
CAST

CAST

Description

cast (input as type)

This function converts the input to the specified type.

BIGINT type

Syntax (BIGINT)

cast (input as BIGINT)

The above function converts the input to BIGINT.

example

  1. Convert a constant, or a column in a table to BIGINT
mysql> select cast (1 as BIGINT);
+-------------------+
| CAST(1 AS BIGINT) |
+-------------------+
|                 1 |
+-------------------+
  1. Convert the loaded raw data to BIGINT
curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, k1=cast(tmp_k1 as BIGINT)"  http://host:port/api/test/bigint/_stream_load
  • Note: When loading data, since the original type is string, floating point values will be turned into NULL, such as 12.0. Doris currently does not truncate raw data.

If you need to convert the above type of data to int, please check the example below:

curl --location-trusted -u root: -T ~/user_data/bigint -H "columns: tmp_k1, k1=cast(cast(tmp_k1 as DOUBLE) as BIGINT)"  http://host:port/api/test/bigint/_stream_load

mysql> select cast(cast ("11.2" as double) as bigint);
+----------------------------------------+
| CAST(CAST('11.2' AS DOUBLE) AS BIGINT) |
+----------------------------------------+
|                                     11 |
+----------------------------------------+
1 row in set (0.00 sec)

Keywords

CAST