Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 配置单元:将字符串转换为整数_String_Hive_User Defined Functions_Hiveql - Fatal编程技术网

String 配置单元:将字符串转换为整数

String 配置单元:将字符串转换为整数,string,hive,user-defined-functions,hiveql,String,Hive,User Defined Functions,Hiveql,我正在寻找一个内置的UDF,用于将配置单元表中字符串列的值转换为整数,以便使用SELECT和ORDER BY进行排序。我查了语言手册,但没用。欢迎提出任何其他建议。cast(str\u列为int) From:它将返回NULL,但如果作为BIGINT,则将显示数字如果该值介于–2147483648和2147483647之间,则cast(string_字段为int)将起作用。else cast(字符串_作为bigint归档)将起作用 hive> select cast('2147483

我正在寻找一个内置的UDF,用于将配置单元表中字符串列的值转换为整数,以便使用SELECT和ORDER BY进行排序。我查了语言手册,但没用。欢迎提出任何其他建议。

cast(str\u列为int)


From:

它将返回NULL,但如果作为BIGINT,则将显示数字

如果该值介于–2147483648和2147483647之间,则cast(string_字段为int)将起作用。else cast(字符串_作为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

好奇的是,这会不会为每个可能的字符串返回一个唯一的int,包括非ascii字符串(例如:外来词或短语)?@wardw123如果字符串是非数字的或太大/太小而不适合
int
数据类型,它将返回
NULL
,请解释您的答案好吗?