【发布时间】:2012-09-03 00:40:33
【问题描述】:
我正在寻找一个内置 UDF 来将我的配置单元表中的字符串列的值转换为整数,以便使用 SELECT 和 ORDER BY 进行排序。我在语言手册中搜索过,但没有用。也欢迎任何其他建议。
【问题讨论】:
标签: string hive user-defined-functions hiveql
我正在寻找一个内置 UDF 来将我的配置单元表中的字符串列的值转换为整数,以便使用 SELECT 和 ORDER BY 进行排序。我在语言手册中搜索过,但没有用。也欢迎任何其他建议。
【问题讨论】:
标签: string hive user-defined-functions hiveql
cast(str_column as int)
【讨论】:
int 数据类型,它将返回NULL
它会返回 NULL 但如果取为 BIGINT 会显示数字
【讨论】:
如果该值介于 –2147483648 和 2147483647 之间,则 cast(string_filed as int) 将起作用。 else cast(string_filed as bigint) 将起作用
hive> select cast('2147483647' as int);
OK
2147483647
hive> select cast('2147483648' as int);
OK
NULL
hive> select cast('2147483648' as bigint);
OK
2147483648
【讨论】: