如何在spark2中阅读Impala中的Kudu

时间:2018-01-10 09:56:42

标签: impala apache-spark-2.0 apache-kudu

我想通过impala在spark2-shell中阅读Kudu,在很多方面都失败了:(

输入spark2-shell:

spark2-shell --jars commons-codec-1.3.jar,hive_metastore.jar,httpclient-4.1.3.jar,ImpalaJDBC41.jar,libthrift-0.9.0.jar,ql.jar,slf4j-log4j12-1.5.11.jar,zookeeper-3.4.6.jar,commons-logging-1.1.1.jar,hive_service.jar,httpcore-4.1.3.jar,libfb303-0.9.0.jar,log4j-1.2.14.jar,slf4j-api-1.5.11.jar,TCLIServiceClient.jar

我的代码:

spark.read.format("jdbc") .option("driver","com.cloudera.impala.jdbc41.Driver")
.option("url","jdbc:impala:Domainname")
//.option("databaseName","default") also use impala::default
.option("dbtable", "impala::default.tablename")
.load()

顺便说一下,desc formatted tablename得到了“impala :: default.tablename”。

输出:

java.lang.NullPointerException
  at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:72)
  at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.<init>(JDBCRelation.scala:113)
  at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:45)
  at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:330)
  at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:152)
  at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:125)
  ... 48 elided

1 个答案:

答案 0 :(得分:1)

最好用Spark直接连接到Kudu然后通过Impala连接 该文件在https://blog.cloudera.com/blog/2017/02/up-and-running-with-apache-spark-on-apache-kudu/

Impala为Spark SQL提供了具有竞争力的性能