hadoop - Hive:如果不存在则创建函数
问题描述
在我的配置单元脚本的开头,我有以下声明:
create function x as y using jar z;
现在,如果该函数已经存在,它会给我一个错误:
Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask. AlreadyExistsException(message:Function x already exists)
如果我使用create function if not exists x as y using jar z;
,我会得到这个错误:
Error while compiling statement: FAILED: ParseException line 7:192 cannot recognize input near 'if' 'not' 'exists' in function identifier
该语句create function if not exists
将在 Impala 中工作,但似乎 hive 不支持它。这是在 Hive 中做类似事情的方法吗?
解决方案
我在 hive 中使用以下语句来创建临时函数。
ADD JAR hdfs:///tmp/udfs/jar1.jar;
DROP FUNCTION IF EXISTS rowid;
CREATE TEMPORARY FUNCTION rowid AS 'com.example.hive.jartest.RowIdUDF';
推荐阅读
- java - 在 tomcat 服务器内为 grpc 托管多个 netty 服务器,应用程序重新部署问题
- c# - ASP.NET Core 使用带有 cookieauthentication 的自定义身份验证处理程序
- python - 尝试运行回归代码。获取有关“linear_model”的错误
- vue.js - 在 Vuejs 中全局导入 Axios 方法
- unity3d - unity - unity 错误cs2001 源文件找不到2018
- php - Wordpress wpdb->删除问题
- php - 使用 PHP 在 XML 中搜索
- ios - 字符串的 AES 128 加密并在 Swift 中生成二进制返回
- salesforce - SOQL 或 Apex 获取 Salesforce 中已安装包的包名称和包许可证 ID
- r - 滑块输入中的颜色刻度线和刻度线标签 - 闪亮