【发布时间】:2018-05-15 12:25:07
【问题描述】:
我在 Eclipse 中使用 apache hive 和 UDF 函数创建。所以当我在我的 sql 查询中调用该函数时,我看到了这个错误:
失败:SemanticException [错误 10014]:第 1:7 行错误的参数“摘要”:没有与(字符串)类 HiveUDF.TokenizeString 匹配的方法。可能的选择:
问题出在哪里?
UDF 类
package HiveUDF;
public class TokenizeString extends UDF {
public List<String> tokenize (Text text) {
List<String> prova = new ArrayList<String>();
if(text == null)
return null;
String[] words = text.toString().split("\\n");
for (String w : words)
prova.add(w);
return prova;
}
}
SQL 表和查询
id bigint
productid string
userid string
profilename string
helpfulnessnumerator int
helpfulnessdenominator int
score float
time int
summary string
text string
CREATE TEMPORARY FUNCTION tokenize_summary as 'HiveUDF.TokenizeString';
select tokenize_summary(summary) from amazonproduct;
【问题讨论】:
-
方法必须命名为
evaluate
标签: java hadoop hive user-defined-functions