一、前言
hive UDF
二、Hive 常用的函数
2.1、关系操作符
Operator |
Operand types |
Description |
A = B |
All primitive types |
TRUE if expression A is equal to expression B otherwise FALSE |
A == B |
None! |
Fails because of invalid syntax. SQL uses =, not == |
A <> B |
All primitive types |
NULL if A or B is NULL, TRUE if expression A is NOT equal to expression B otherwise FALSE |
A < B |
All primitive types |
NULL if A or B is NULL, TRUE if expression A is less than expression B otherwise FALSE |
A <= B |
All primitive types |
NULL if A or B is NULL, TRUE if expression A is less than or equal to expression B otherwise FALSE |
A > B |
All primitive types |
NULL if A or B is NULL, TRUE if expression A is greater than expression B otherwise FALSE |
A >= B |
All primitive types |
NULL if A or B is NULL, TRUE if expression A is greater than or equal to expression B otherwise FALSE |
A IS NULL |
all types |
TRUE if expression A evaluates to NULL otherwise FALSE |
A IS NOT NULL |
All types |
TRUE if expression A evaluates to NULL otherwise FALSE |
A LIKE B |
strings |
NULL if A or B is NULL, TRUE if string A matches the SQL simple regular expression B, otherwise FALSE. The comparison is done character by character. The _ character in B matches any character in A(similar to . in posix regular expressions) while the % character in B matches an arbitrary number of characters in A(similar to .* in posix regular expressions) e.g. 'foobar' like 'foo' evaluates to FALSE where as 'foobar' like 'foo_ _ _' evaluates to TRUE and so does 'foobar' like 'foo%' |
A RLIKE B |
strings |
NULL if A or B is NULL, TRUE if string A matches the Java regular expression B(See Java regular expressions syntax), otherwise FALSE e.g. 'foobar' rlike 'foo' evaluates to FALSE where as 'foobar' rlike '^f.*r$' evaluates to TRUE |
A REGEXP B |
strings |
Same as RLIKE |
2.2、代数操作符
Operator |
Operand types |
Description |
A + B |
All number types |