SELECT CAST(user_id AS DOUBLE) AS new_id;
SELECT CAST('2015-10-01 00:00:00' AS DATETIME) AS new_date;
SELECT CAST(ARRAY(1,2,3) AS ARRAY<STRING>);
SELECT CONCAT_WS(',', CAST(ARRAY(1, 2) AS ARRAY<STRING>));
使用说明和限制
将DOUBLE类型转为BIGINT类型时,小数部分会被截断,例如
CAST(1.6 AS BIGINT) = 1
。
满足DOUBLE格式的STRING类型转换为BIGINT时,会先将STRING转换为DOUBLE,再将DOUBLE转换为BIGINT,因此,小数部分会被截断,例如
CAST(“1.6” AS BIGINT) = 1
。
满足BIGINT格式的STRING类型可以被转换为DOUBLE类型,小数点后保留一位,例如
CAST(“1” AS DOUBLE) = 1.0
。