如何在spark2中阅读 Impala 的kudu

oknrviil  于 2021-06-26  发布在  Impala
关注(0)|答案(1)|浏览(460)

我想读《 Impala 在斯巴克2炮弹中的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()

顺便说一下,我得到了“impala::default.tablename” desc formatted 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
hvvq6cgz

hvvq6cgz1#

最好直接用spark连接到kudu,然后通过impala连接,因为这里有文档https://blog.cloudera.com/blog/2017/02/up-and-running-with-apache-spark-on-apache-kudu/
impala为spark sql提供了极具竞争力的性能

相关问题