hive-hbase集成抛出classnotfoundexception NULL ::字符变化 [英] hive-hbase integration throws classnotfoundexception NULL::character varying

查看:355
本文介绍了hive-hbase集成抛出classnotfoundexception NULL ::字符变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继此链接 https://cwiki.apache.org / confluence / display / Hive / HBaseIntegration#HBaseIntegration-HiveMAPtoHBaseColumnFamily



我试图整合hive和hbase,我在hive-site中配置了这个配置。 xml:

 < property> 
< name> hive.aux.jars.path< / name>
<值>
file:///$HIVE_HOME/lib/hive-hbase-handler-2.0.0.jar,
file:///$HIVE_HOME/lib/hive-ant-2.0.0.jar,
file:///$HIVE_HOME/lib/protobuf-java-2.5.0.jar,
file:///$HIVE_HOME/lib/hbase-client-1.1.1.jar,
file:///$HIVE_HOME/lib/hbase-common-1.1.1.jar,
file:///$HIVE_HOME/lib/zookeeper-3.4.6.jar,
file: ///$HIVE_HOME/lib/guava-14.0.1.jar
< / value>
< / property>

然后在hbase中创建一个名为'ts:testTable'的表:

  hbase>创建'ts:testTable','戳'
hbase> put'ts:testTable','10000','pokes:value','val_10000'
hbase> put'ts:testTable','10001','pokes:value','val_10001'
...

hbase> scan'ts:testTable'
ROW COLUMN + CELL
10000 column = pokes:value,timestamp = 1462782972084,value = val_10000
10001 column = pokes:value,timestamp = 1462783514212,value = val_10001
....

然后在配置单元中创建外部表:

  Hive> CREATE EXTERNAL TABLE hbase_test_table(key int,value string)
STORED BY'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES(hbase.columns.mapping=:key,pokes :value)
TBLPROPERTIES(hbase.table.name=ts:testTable,
hbase.mapred.output.outputtable=ts:testTable);

到目前为止这么好。但是,当我试图从测试表中选择数据时,抛出异常:

  Hive> select * from hbase_test_table; 
FAILED:RuntimeException java.lang.ClassNotFoundException:NULL ::字符变化
错误:编译语句时出错:FAILED:RuntimeException java.lang.ClassNotFoundException:NULL ::字符变化(状态= 42000,代码= 40000)

我缺少什么?

我正在用HBase 1.2.1试用Hive 2.0.0

解决方案

好吧,我想通了,NULL ::字符变化不是配置单元的一部分,它来自Postgresql,因为我使用它作为Metastore的后端。但问题是Hive不能识别来自Postgresql的这个异常。我们为Hive 2.0.0提供了以下代码:

  300:if(inputFormatClass == null){
301 :try {
302:String className = tTable.getSd()。getInputFormat();
303:if(className == null){
304:if(getStorageHandler()== null){
305:return null;
306:}
307:inputFormatClass = getStorageHandler()。getInputFormatClass();
308:} else {
309:inputFormatClass =(Class< ;? extends InputFormat>)
310:Class.forName(className,true,Utilities.getSessionSpecifiedClassLoader());
}

第302行不会返回空。因此310行会尝试加载一个不存在的类。这就是程序失败的原因。



我相信这是一个兼容的错误,修复方法它是改变我讨厌的数据库。所以我只是简单地用

 替换302 if(className == null || className.toLowerCase()。startsWith(null: :)){

对getOutputFormat()方法做同样的事情,然后重新编译jar,就是这样。


Following with this link https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration#HBaseIntegration-HiveMAPtoHBaseColumnFamily

I'm trying to integrate hive and hbase, I have this configuration in hive-site.xml:

<property>
  <name>hive.aux.jars.path</name>
  <value>
    file:///$HIVE_HOME/lib/hive-hbase-handler-2.0.0.jar,
    file:///$HIVE_HOME/lib/hive-ant-2.0.0.jar,
    file:///$HIVE_HOME/lib/protobuf-java-2.5.0.jar,
    file:///$HIVE_HOME/lib/hbase-client-1.1.1.jar,
    file:///$HIVE_HOME/lib/hbase-common-1.1.1.jar,
    file:///$HIVE_HOME/lib/zookeeper-3.4.6.jar,
    file:///$HIVE_HOME/lib/guava-14.0.1.jar
  </value>
</property>

Then create a table named 'ts:testTable' in hbase:

hbase> create 'ts:testTable','pokes'
hbase> put 'ts:testTable', '10000', 'pokes:value','val_10000'
hbase> put 'ts:testTable', '10001', 'pokes:value','val_10001'
...

hbase> scan  'ts:testTable'
ROW                       COLUMN+CELL
 10000                    column=pokes:value, timestamp=1462782972084, value=val_10000
 10001                    column=pokes:value, timestamp=1462783514212, value=val_10001
....

And then create external table in hive:

Hive> CREATE EXTERNAL TABLE hbase_test_table(key int, value string )
       STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
       WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key, pokes:value")
       TBLPROPERTIES ("hbase.table.name" = "ts:testTable",
       "hbase.mapred.output.outputtable" = "ts:testTable");

So far so good. But when I tried to select data from the test table, exception was thrown:

Hive> select * from hbase_test_table;
FAILED: RuntimeException java.lang.ClassNotFoundException: NULL::character varying
Error: Error while compiling statement: FAILED: RuntimeException java.lang.ClassNotFoundException: NULL::character varying (state=42000,code=40000)

Am I missing anything?

I'm trying Hive 2.0.0 around with HBase 1.2.1

解决方案

Ok, I figured it out, the "NULL::character varying" is not a part of hive, it is coming from Postgresql, as I'm using it as the back end of Metastore. But the problem is Hive doesn't recognizes this exception from Postgresql. We have the following code for Hive 2.0.0:

300: if (inputFormatClass == null) {
301:   try {
302:     String className = tTable.getSd().getInputFormat();
303:     if (className == null) {
304:       if (getStorageHandler() == null) {
305:         return null;
306:       }
307:      inputFormatClass = getStorageHandler().getInputFormatClass();
308:  } else {
309:  inputFormatClass = (Class<? extends InputFormat>)
310:    Class.forName(className, true, Utilities.getSessionSpecifiedClassLoader());
    }

Line 302 will not return null which supposed to. so that the line 310 will try to load a non-existing class in. That's the reason why program failed.

I believe it is a compatible bug, the way to fix it is change the database which I hate to. So I just simply replaced 302 with

if (className == null || className.toLowerCase().startsWith("null::")) {

And do same thing to the getOutputFormat() method, then re-compile the jar, That's it.

这篇关于hive-hbase集成抛出classnotfoundexception NULL ::字符变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆