Impala添加UDF

  |   0 评论   |   2,302 浏览

查看所有函数

[s3:21000] > show functions in _impala_builtins;
Query: show functions in _impala_builtins
+--------------+-------------------------------------------------+-------------+---------------+
| return type | signature | binary type | is persistent |
+--------------+-------------------------------------------------+-------------+---------------+
| BIGINT | abs(BIGINT) | BUILTIN | true |
| DECIMAL(*,*) | abs(DECIMAL(*,*)) | BUILTIN | true |dc

创建UDF

[s3:21000] > use udfs;
Query: use udfs
[s3:21000] > create function md5(string) returns string location '/system/hive/lib/hive-function-0.0.1-SNAPSHOT.jar' symbol='com.cxy7.hive.udf.UDFMd5Hex';
Query: create function md5(string) returns string location '/system/hive/lib/hive-function-0.0.1-SNAPSHOT.jar' symbol='com.cxy7.hive.udf.UDFMd5Hex'
Fetched 0 row(s) in 0.64s

使用UDF

[s3:21000] > select udfs.md5(casttostring(id)) from dual;
Query: select udfs.md5(casttostring(id)) from dual
+----------------------------------+
| udfs.md5(casttostring(id)) |
+----------------------------------+
| c4ca4238a0b923820dcc509a6f75849b |
+----------------------------------+
Fetched 1 row(s) in 0.57s

查看UDF结果

[s3:21000] > show functions in udfs;
Query: show functions in udfs
+-------------+-------------------------+-------------+---------------+
| return type | signature | binary type | is persistent |
+-------------+-------------------------+-------------+---------------+
| STRING | get_json_object(STRING) | JAVA | false |
| STRING | md5(STRING) | JAVA | false |
| STRING | xml2json(STRING) | JAVA | false |
+-------------+-------------------------+-------------+---------------+
Fetched 3 row(s) in 0.01s

参考资料:

Using Hive UDFs with Impala


读后有收获可以支付宝请作者喝咖啡