函数名称 | 语法 | 说明 |
cast 函数 | cast(x as type) | 转换 x 的数据类型。 使用 cast 函数转换数据类型时,如果某个值转换失败,将终止整个查询与分析操作。 |
try_cast 函数 | try_cast(x as type) | 转换 x 的数据类型。 使用 try_cast 函数转换数据类型时,如果某个值转换失败,该值返回 NULL,并跳过该值继续处理。 |
typeof 函数 | typeof(x) | 返回 x 的数据类型。 |
cast(x as type)
参数 | 说明 |
x | 参数值可以为任意类型。 |
type | SQL 数据类型,可选值为 bigint、varchar、double、boolean、timestamp、decimal、array 或 map。 |
from_unixtime(__TIMESTAMP__/1000, 'Asia/Shanghai'))或手动添加时区偏移(例如 cast(__TIMESTAMP__+8*60*60*1000 as timestamp)或cast(__TIMESTAMP__ as timestamp)+ INTERVAL 8 HOUR)。* | select cast(0.01 as bigint)
__TIMESTAMP__转换为 TIMESTAMP 类型。* | select cast(__TIMESTAMP__ as timestamp)
try_cast(x as type)
参数 | 说明 |
x | 参数值可以为任意类型。 |
type | SQL 数据类型,可选值为 bigint、varchar、double、boolean、timestamp、decimal、array 或 map。 |
* | select try_cast(remote_user as varchar)
索引的数据类型 | SQL 的数据类型 |
long | bigint |
text | varchar |
double | double |
json | varchar |
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback