string Hive:将字符串转换为整数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12346750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hive: Convert String to Integer
提问by Srinivas
I am looking for a Built-in UDF to convert values of a string column to integer in my hive table for sorting using SELECT and ORDER BY. I searched in the Language Manual, but no use. Any other suggestions also welcome.
我正在寻找一个内置的 UDF 来将字符串列的值转换为我的 hive 表中的整数,以便使用 SELECT 和 ORDER BY 进行排序。我在语言手册中搜索过,但没有用。任何其他建议也欢迎。
回答by Joe K
cast(str_column as int)
cast(str_column as int)
回答by ravi
It would return NULL but if taken as BIGINT would show the number
它会返回 NULL 但如果被视为 BIGINT 会显示数字