Hive ua 解析器 UDF 给出 IOException
Posted
技术标签:
【中文标题】Hive ua 解析器 UDF 给出 IOException【英文标题】:Hive ua parser UDF gives IOException 【发布时间】:2016-04-15 09:49:44 【问题描述】:我有以String
格式存储的用户代理字符串。
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/36.0.1985.143 Safari/537.36
我想从用户代理字符串中提取浏览器。所以我使用了ua-parser-java 库。
Hive UDF 代码如下:
public class BrowserInfo extends UDF
public Text evaluate(Text input)
if(input == null) return null;
String uaString = input.toString();
Parser uaParser= null;
try
uaParser = new Parser();
catch (IOException e)
e.printStackTrace();
Client c = uaParser.parse(uaString);
return new Text(c.userAgent.family);
它给了我以下异常。
Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public org.apache.hadoop.io.Text dhruv.udf.BrowserInfo.evaluate(org.apache.hadoop.io.Text)
on object dhruv.udf.BrowserInfo@5379d8 of class dhruv.udf.BrowserInfo
with arguments "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)":org.apache.hadoop.io.Text of size 1
尝试使用String
而不是Text
,但得到相同的异常。
如果没有配置单元,此代码可以完美运行。
更新:
hadoop 或 hive 的日志中没有关于此的详细信息。
【问题讨论】:
【参考方案1】:要解决错误,您需要确保几件事-
-
regexes.yaml 存在于打包的 .jar 文件中,并且它的路径在 parser.java 中是正确的
所有依赖的 jar 也打包在最终的 .jar 文件中。
希望这会有所帮助。
【讨论】:
以上是关于Hive ua 解析器 UDF 给出 IOException的主要内容,如果未能解决你的问题,请参考以下文章
Hive 给出 SemanticException [错误 10014]:运行我的 UDF 时