Hive函数collect_set、concat_ws、concat、if

hive查看函数声明:desc function 函数名;

collect_set函数

collect_set(x) - Returns a set of objects with duplicate elements eliminated
翻译:collect_set(x)-返回一组删除了重复元素的对象

图1.只允许一个入参,参数可为字段,可为常量。
图2.案例
图3 4.返回值是数组 array,成员类型与源类型相同。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

concat_ws函数

concat_ws(separator, [string | array(string)]+) - returns the concatenation of the strings separated by the separator
翻译:concat ws(separator,[string | array(string)]+)-返回由分隔符分隔的字符串的连接

1.参数1为分隔符
2.可有多个参数,第二个及以后的参数为字符串或者字符串数组
在这里插入图片描述
在这里插入图片描述

concat函数

concat(str1, str2, … strN) - returns the concatenation of str1, str2, … strN or concat(bin1, bin2, … binN) - returns the concatenation of bytes in binary data bin1, bin2, … binN
翻译:concat(str1,str2,…strN)返回str1,str2,…strN的连接或concat(bin1,bin2,binN)返回二进制数据bin1、bin2、…binN中字节的连接。

if函数

IF(expr1,expr2,expr3) - If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used.
翻译:如果(expr1,expr2,expr3)-如果expr1为真(expr1<>0和expr1<>NULL),则IF()返回expr2;否则返回expr3。IF()返回数值或字符串值,具体取决于使用该值的上下文。

猜你喜欢

转载自blog.csdn.net/AnlaGodness/article/details/104162510