2015-11-21 31 views
0

我从教程中创建了自己的UDTF函数,并将jar加载到配置单元中。现在我想创建自己的函数来调用UDTF。Hive:我如何构建UDTF?

statement.executeUpdate("ADD JAR /home/hfu/myjar.jar;"); 
statement.executeUpdate("CREATE TEMPORARY FUNCTION my_function AS 'com.effectivemeasure.hive.UDFT'"); 

我得到一个例外,当我运行最后CodeSnippet:

Exception in thread "main" java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask 
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:296) 
    at org.apache.hive.jdbc.HiveStatement.executeUpdate(HiveStatement.java:406) 
    at connectToHiveServer2.main(connectToHiveServer2.java:74) 

我做了什么错?

下面是我使用的教程:

http://beekeeperdata.com/posts/hadoop/2015/07/26/Hive-UDTF-Tutorial.htmlhttp://www.ericlin.me/hive-user-defined-aggregation-function-udaf

回答

1

我猜你想通过JDBC使用UDF。 请尝试以下操作:

  1. 删除;在每行
  2. 使用年底执行的代替的executeUpdate
  3. 确保罐子存在在蜂巢服务器

3号值得评论。当您从shell执行配置单元查询时,您的配置单元shell会将UDTF jar与其他配置单元jar一起打包并提交为hadoop作业。使用jdbc时,此作业由配置单元服务器完成,因此JAR必须存储在该路径中,但配置单元服务器上的可能与您运行程序的机器不同。