我有一个Hive,它在蜂箱终端中工作得很好,我想通过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';"第一个‘蜂巢-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 foundhive是否支持shell脚本,如果它做错了什么,我正在做什么。提前感谢
发布于 2016-05-17 22:03:03
每次对hive -e的调用都会产生一个新的进程,其中包含一个新的蜂巢外壳,它没有对上一个进程的记忆,所以蜂窝“忘记”了UDF所在的位置.一种解决方案是将它们链接在一个命令中,但是最好将所有的单元格命令放在一个文件中(例如"commands.hql"),使用hive -f commands.hql而不是-e。
文件将如下所示:
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';"发布于 2016-05-18 18:58:46
您可以让它同时与hive -e和hive -f一起工作。
hive -e "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';"将它们创建为一个文件并使用hive -f hive_file.hql也同样有效。
https://stackoverflow.com/questions/37208980
复制相似问题