4.Hive 查询出错 Exception in thread “main“ java.lang.IncompatibleClassChangeError

Hive和Hadoop里面guava jar包的版本兼容性问题导致的hive 查询失败

1.在hive 里面做查询,出错了

hive> select * from struct_score; 
Exception in thread "main" java.lang.IncompatibleClassChangeError: Class com.google.common.
collect.ImmutableSortedMap does not implement the requested interface java.util.NavigableMap
    at org.apache.calcite.schema.Schemas.gatherLattices(Schemas.java:498)

2.原因

guava jar包在hadoop 里面和在hive 里面不兼容。

[hadoop@big81 current]$ ll /data02/apache-hive-3.1.2-bin/lib/guava-19.0.jar
-rw-r--r-- 1 hadoop hadoop 2308517 Apr 23 12:03 /data02/apache-hive-3.1.2-bin/lib/guava-19.0.jar
[hadoop@big81 current]$ ll /data02/hadoop/share/hadoop/common/lib/guava-11.0.2.jar
-rw-r--r-- 1 hadoop hadoop 1648200 Jan 12 17:58 /data02/hadoop/share/hadoop/common/lib/guava-11.0.2.jar
 

hive3.1.2里面默认的guava版本是:19.0

Hadoop3.1.1 里面的guava版本是:11.0.2 。我是将hadoop里面的guava-11.0.2.jar 复制到了hive里面去。所以报错,hive里面保持默认的版本guava-19.0.jar 可以。hadoop里面使用guava-11.0.2.jar

就正常了。

3.查询验证

hive> select * from score;
OK
biansutao 数学:80,语文:89,英语:95    NULL
jobs 语文:60,数学:80,英语:99    NULL
Time taken: 0.166 seconds, Fetched: 2 row(s)