在多 hiveserver 中共享 UDF [英] Share UDFs in Multi hiveserver

查看:49
本文介绍了在多 hiveserver 中共享 UDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的生产环境中,我们有多个 hiveserver2 以实现高可用性.用户通过运行创建永久 UDF

In our production environment,we have multi hiveserver2 for high availibility.User create permenent UDFs by running

beeline -u "jdbc:hive2//hs1.name.com"    
add jar <hdfs://ns:8020/path/udf.jar>
create  function myfunc as 'com.test.udf.UDF_CLASS' using jar 'hdfs://ns:8020/path/udf.jar'

用户连接到 hs1.name.com 没问题,但是当使用 beeline 连接另一个 hiveserver2 调用 UDF 时,用户得到 function not found ERROR,如

User connect to hs1.name.com is OK,but user get function not found ERROR when using beeline connect another hiveserver2 to call the UDF,like

beeline -u "jdbc:hive2//hs2.name.com"
select myfunc(id) from table1  

错误信息是

错误:编译语句时出错:FAILED: SemanticException [Error 10011]: Line 1:7 Invalid function 'myfunc' (state=42000,code=10011)`

Error: Error while compiling statement: FAILED: SemanticException [Error 10011]: Line 1:7 Invalid function 'myfunc' (state=42000,code=10011)`

在hs2.name.com上重启hiveserver2后,用户可以正确调用UDF.
有没有办法不重启 hiveserver2 而是告诉 hiveserver2 从 Metastore 重新加载 UDF 信息?

After restart hiveserver2 on hs2.name.com,user can call the UDF correctly.
Is there someway not to restart hiveserver2 but told hiveserver2 to reload UDFs information from metastore?

感谢@Kishore,重新加载功能很棒!

Thanks @Kishore, reload function is great!

推荐答案

USE RELOAD FUNCTION;

从 HIVE-2573 开始,在一个 Hive CLI 会话中创建永久函数可能不会反映在 HiveServer2 或其他 Hive CLI 会话中,如果它们在创建函数之前启动.在 HiveServer2 或 HiveCLI 会话中发出 RELOAD FUNCTION 将允许它获取对不同 HiveCLI 会话可能已完成的永久功能的任何更改.

As of HIVE-2573, creating permanent functions in one Hive CLI session may not be reflected in HiveServer2 or other Hive CLI sessions, if they were started before the function was created. Issuing RELOAD FUNCTION within a HiveServer2 or HiveCLI session will allow it to pick up any changes to the permanent functions that may have been done by a different HiveCLI session.

ref - https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Create/Drop/ReloadFunction

这篇关于在多 hiveserver 中共享 UDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆