spark官网文档也愚人

在spark sql中使用hive的ddl语句时报出以下异常:

ERROR Task: Failed with exception Unable to alter table. Invalid method name: 'alter_table_with_cascade'
org.apache.hadoop.hive.ql.metadata.HiveException: Unable to alter table. Invalid method name: 'alter_table_with_cascade'

版本说明:spark 1.5.1 hive 0.13

见到这个异常感到很疑惑,'alter_table_with_cascade'应该时hive 1以后出来的,0.13当然不支持,spark怎么会调用这个功能,初步判断是配置文件没有更新,检查了一下,排除配置文件的问题

放到本地来调试一下,一切正常,没有报这个异常,分析了一下本地环境的差异,本地hive是直接连mysql 做metastore的,而发生异常的测试环境的hive是用cdm装的,用了hive server2的远程方式连接metastore

想到了编译spark时使用的-Phive -Phive-thriftserver参数,怀疑spark使用了hive 1以上版本的类库进行编译

查了下官网,发现spark 1.5.1是默认用的hive0.13.1,这就郁闷了



 

继续查官网,坑爹的发现,原来默认用的是hive1.2.1的类库进行编译的



 

查看源码中的CHANGES.TXT,也有以下记录

[SPARK-10584] [SQL] [DOC] Documentation about the compatible Hive version is wrong.
  Kousuke Saruta <[email protected]>
  2015-09-19 01:59:36 -0700
  Commit: aaae67d, github.com/apache/spark/pull/8776

找到了问题,就好解决了,按上图所提示的,在classpath里加入hive0.13的jar即可

在spark-default.xml中加入以下配置

spark.sql.hive.metastore.version=0.13.1
spark.sql.hive.metastore.jars=/opt/cloudera/parcels/CDH/lib/hive/lib/*:/opt/cloudera/parcels/CDH/lib/hadoop/client/*

猜你喜欢

转载自lb4java.iteye.com/blog/2366956