HIVE:UDF错误FAILED:找不到类<classname> </classname>

时间:2015-03-26 21:43:07

标签: hadoop jar hive user-defined-functions

我正在尝试将myjar.jar用作HIVE中的UDF函数,如下所示,

echo "Add myjar.jar"
$HIVE_HOME/bin/hive -e "ADD JAR  /gpfs/user/username/HIVE/myjar.jar;"

echo "List myjar.jar, this is showing local directory path"
$HIVE_HOME/bin/hive -e "list jar;"


$HIVE_HOME/bin/hive -e "drop function if exists myfunction;"

echo "Create temporary function, my class name is UpperCase"

$HIVE_HOME/bin/hive -e "CREATE TEMPORARY FUNCTION myfunction AS 'Upper.UpperCase';"

$HIVE_HOME/bin/hive -e "SELECT myfunction(line) FROM doc where line='COCO';" 

但我收到了以下错误,

FAILED: Class Upper.UpperCase not found
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask

我怀疑问题可能是我的jar没有被复制到本地节点目录。但我不确定。

1 个答案:

答案 0 :(得分:2)

ADD JAR仅适用于运行它的会话 - 但在您的情况下,您正在为每个语句运行新会话。相反,您应该将所有语句放在一个脚本中,并将其命名为:

$HIVE_HOME/bin/hive -f yourscript.sql