【发布时间】:2016-05-13 11:31:35
【问题描述】:
我有一个在 hive 终端中运行良好的 Hive Udf,我想要通过 shell 脚本执行它。 在蜂巢终端上,我可以执行以下命令:
use mashery_db;
add jar hdfs://nameservice1/tmp/nextdata_aggregations/custom_jar/readerCheck.jar;
add file hdfs://nameservice1/tmp/GeoLite2-City.mmdb;
CREATE TEMPORARY FUNCTION geoip AS 'com.mashery.nextdata.hive.udf.GeoIPGenericUDF';
但是当我在 shell 脚本中添加上述代码时
hive -e "use mashery_db;"
hive -e "add jar hdfs://nameservice1/tmp/nextdata_aggregations/custom_jar/readerCheck.jar;"
hive -e "add file hdfs://nameservice1/tmp/GeoLite2-City.mmdb;"
hive -e "CREATE TEMPORARY FUNCTION geoip AS 'com.mashery.nextdata.hive.udf.GeoIPGenericUDF';"
第一个“hive -e”运行良好并添加了 jar,但最后一个创建临时函数不起作用。我收到以下错误:
FAILED: ParseException line 1:35 mismatched input 'com' expecting StringLiteral near 'AS' in create function statement
我也试过用单引号
hive -e "CREATE TEMPORARY FUNCTION geoip AS 'com.mashery.nextdata.hive.udf.GeoIPGenericUDF';"
然后我得到FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask
FAILED: Class com.mashery.nextdata.hive.udf.GeoIPGenericUDF not found
hive Udf 是否支持 shell 脚本,如果它做错了我在做什么。提前致谢
【问题讨论】:
-
尝试导入 jar 并在一次调用 hive 中创建函数。即
hive -e "add jar path_to_jar/foo.jar; create temporary function foo as 'com.package.UDF';" -
@GoBrewers14 谢谢它对我有用 :-)