-
Hive Internal Error java.lang.NullPointerException5
刚刚接触hive,最近在研究UDAF,自己写了一个,代码如下:
package com.udaf.concat;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hive.ql.exec.UDAF;
import org.apache.hadoop.hive.ql.exec.UDAFEvaluator;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFSum;
public class myConcat extends UDAF{
static final Log LOG = LogFactory.getLog(GenericUDAFSum.class.getName());
public static class ConcatUDAFEvaluator implements UDAFEvaluator{
public static class PartialResult{
String result;
String delimiter;
}
private PartialResult partialResult;
@Override
public void init() {
partialResult.delimiter = new String("");
partialResult.result = new String("");
}
public boolean iterate(String value, String delimiter){
if(value == null){
return true;
}
if(partialResult == null){
partialResult = new PartialResult();
partialResult.result = new String("");
if(delimiter == null || "".equals(delimiter)){
partialResult.delimiter = new String(",");
}
else{
partialResult.delimiter = new String(delimiter);
}
}
if( partialResult.result.length() > 0){
partialResult.result = partialResult.result.concat(partialResult.delimiter);
}
partialResult.result = partialResult.result.concat(value);
return true;
}
public PartialResult terminatePartial() {
return partialResult;
}
public boolean mergr(PartialResult other) {
if(other == null){
return true;
}
if(partialResult == null){
partialResult = new PartialResult();
partialResult.result = new String(other.result);
partialResult.delimiter = new String(other.delimiter);
}
else{
if( partialResult.result.length() > 0){
partialResult.result = partialResult.result.concat(other.delimiter);
}
partialResult.result = partialResult.result.concat(other.result);
}
return true;
}
public String terminate() {
return partialResult.result;
}
}
}
在hive端:
>add jar /usr/Download/testUDAF.jar;
>creare temporatry function myconcat as 'com.udaf.concat.myConcat';
>select age,myconcat(name,',') from t_udaf group by age;
---------------------------------------------------------------------------
附t_udaf 表结构:
hive> describe extended t_udaf;
OK
namestring
ageint
Detailed Table InformationTable(tableName:t_udaf, dbName:test, owner:root, createTime:1418808574, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:name, type:string, comment:null), FieldSchema(name:age, type:int, comment:null)], location:hdfs://lntusl:9000/usr/hive/warehouse/test.db/t_udaf, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=/t, field.delim=/t}), bucketCols:[], sortCols:[], parameters:{}), partitionKeys:[], parameters:{numPartitions=0, numFiles=1, transient_lastDdlTime=1418808709, numRows=0, totalSize=135, rawDataSize=0}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)
Time taken: 0.111 seconds
但是,执行如下语句,报错:
hive> select age,myconcat(name,',') from t_udaf group by age;
FAILED: Hive Internal Error: java.lang.NullPointerException(null)
java.lang.NullPointerException
at org.apache.hadoop.hive.ql.udf.generic.GenericUDFUtils$ConversionHelper.<init>(GenericUDFUtils.java:215)
at org.apache.hadoop.hive.ql.udf.generic.GenericUDAFBridge$GenericUDAFBridgeEvaluator.init(GenericUDAFBridge.java:129)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getGenericUDAFInfo(SemanticAnalyzer.java:2452)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genGroupByPlanGroupByOperator1(SemanticAnalyzer.java:2740)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genGroupByPlanMapAggr1MR(SemanticAnalyzer.java:3677)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genBodyPlan(SemanticAnalyzer.java:6125)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:6762)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:7531)
at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:243)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:431)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:336)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:909)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:258)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:215)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:406)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:689)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:557)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
求指点!。~。2014年12月18日 10:53
目前还没有答案
相关推荐
- hive分区导致FAILED: Hive Internal Error: java.lang.NullPointerException(null)
- hive java insert_Hive Insert - 失败,异常无法更改表。显示java.lang.NullPointerException...
- 异常之java.lang.nullpointerexception 怎么解决及出现原因?
- 【Bug修复】java.lang.IllegalArgumentException、java.lang.NullPointerException 问题解决修复
- java.lang.NullPointerException的6种解决方法
相关推荐
"java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver" 解决方案 [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. 解决了jsp连接 sql server 2000的问题
Caused by: java.sql.SQLException: java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver at com.trs.gateway.commons.hive.HiveFeature.getConnection(HiveFeature.java:57) at ...
解决方案:Exceptionin thread "main" java.lang.UnsatisfiedLinkError:org.apache.hadoop.util.NativeCrc32.nativeCo
Caused by: java.sql.SQLException: java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver at com.trs.gateway.commons.hive.HiveFeature.getConnection(HiveFeature.java:57) at ...
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient 解决方法 ...
[HiveServer2-Handler-Pool: Thread-55]: Error opening session: org.apache.hive.service.cli.HiveSQLException: Failed to open new session: java.lang.IllegalArgumentException: Cannot modify hive.query....
Hive错误之 Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask错误分析_xiaohu21的博客-CSDN博客.mht
Hive Hook 是 Atlas 提供的一个关键组件,用于实现在 Apache Hive 操作时的元数据跟踪和审计。当你在处理 Hive 数据时,Hive Hook 可以捕获对表、分区等对象的创建、更新和删除操作,将这些元数据事件上报给 Atlas,...
出现此问题时使用:java.lang.NullPointerException at org.json.JSONObject.(JSONObject.java:144) at org.apache.sqoop.util.SqoopJsonUtil.getJsonStringforMap(SqoopJsonUtil.java:43) at org.apache.sqoop....
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient 通过控制台的...
Hive JDBC驱动是连接Hadoop生态系统中的Hive数据仓库的重要桥梁,它允许用户通过Java数据库连接(JDBC)标准来访问Hive。在Hive 2.5.15和2.6.1这两个版本中,都包含了对Hive查询语言(HQL)的支持以及对大数据处理的...
可以通过调整`hive.tez.container.size`和`hive.tez.java.opts`来增加内存分配,例如设置前者为9216MB,后者为6144MB。同时,如果物理内存或虚拟内存超出限制,需要调整YARN的配置,如`yarn.scheduler.minimum-...
import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.ha
at org.apache.hadoop.hive.ql.io.orc.ReaderImpl.(ReaderImpl.java:62) at org.apache.hadoop.hive.ql.io.orc.OrcFile.createReader(OrcFile.java:89) at org.apache.hadoop.hive.ql.io.orc....
在本文档的上下文中,错误发生在启动Azkaban时,具体表现为 `java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.toImmutableMap`。Azkaban是一个开源的工作流执行器,用于调度和管理大数据处理...
《Ranger 2.1.0 Hive 插件详解》 在大数据安全领域,Apache Ranger 是一款不可或缺的工具,它提供了全面的权限管理和审计功能,适用于多种数据存储系统,包括 Hive。本文将深入探讨 Ranger 2.1.0 版本针对 Hive 的...
apache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tarapache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tar apache-hive-2.1.1-bin.tarapache-hive-2.1.1-bin.tar apache-hive-2.1.1-...
在本案例中,"ranger-2.0.0-hive-plugin.tar.gz" 是Apache Ranger为Hive服务编译好的插件包,旨在简化Ranger在Hive上的部署过程,避免用户自行编译可能遇到的复杂性和时间消耗。 Ranger Hive 插件的主要功能包括: ...
含两个文件hive-jdbc-3.1.2-standalone.jar和apache-hive-3.1.2-bin.tar.gz 含两个文件hive-jdbc-3.1.2-standalone.jar和apache-hive-3.1.2-bin.tar.gz 含两个文件hive-jdbc-3.1.2-standalone.jar和apache-hive-...