gpt4 book ai didi

apache-spark - spark hbase 连接器 - 异常 "java.lang.UnsupportedOperationException: empty.tail"

转载 作者:行者123 更新时间:2023-12-01 11:21:17 26 4
gpt4 key购买 nike

我们使用的是 HDP 2.4.2,spark 1.6 是用 Scala 2.10.5 编译的。 Hbase 版本为 1.1.2.2.4.2.0-258

环境是一个基本的开发集群(<10 个节点),hbase 和 spark 在集群模式下运行。

尝试使用 spark hbase 连接器将 soem 数据从 hbase 获取到 spark 中的数据帧失败,并出现以下错误 -

Exception in thread "main" java.lang.UnsupportedOperationException: empty.tail
at scala.collection.TraversableLike$class.tail(TraversableLike.scala:445)
at scala.collection.mutable.ArraySeq.scala$collection$IndexedSeqOptimized$super$tail(ArraySeq.scala:45)
at scala.collection.IndexedSeqOptimized$class.tail(IndexedSeqOptimized.scala:123)
at scala.collection.mutable.ArraySeq.tail(ArraySeq.scala:45)
at org.apache.spark.sql.execution.datasources.hbase.HBaseTableCatalog.initRowKey(HBaseTableCatalog.scala:150)
at org.apache.spark.sql.execution.datasources.hbase.HBaseTableCatalog.<init>(HBaseTableCatalog.scala:164)
at org.apache.spark.sql.execution.datasources.hbase.HBaseTableCatalog$.apply(HBaseTableCatalog.scala:239)
at hbaseReaderHDPCon$.main(hbaseReaderHDPCon.scala:42)
at hbaseReaderHDPCon.main(hbaseReaderHDPCon.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$runMain(SparkSubmit.scala:731)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

在我的代码的第 42 行 - 这正在发生 -
val cat =
s"""{
|"table":{"namespace":"myTable", "name":"person", "tableCoder":"PrimitiveType"},
|"rowkey":"ROW",
|"columns":{
|"col0":{"cf":"person", "col":"detail", "type":"string"}
|}
|}""".stripMargin
val scon = new SparkConf()
val sparkContext = new SparkContext(scon)

最佳答案

鉴于您的代码,我认为您目录中的“列”字段缺少行键。
下面是一个对我有用的例子。我正在使用 Spark 2.0 (SparkSession) 但它应该与 Spark 1.6 一起使用:

    val catalog =
s"""{
|"table":{"namespace":"default", "name":"person"},
|"rowkey":"id",
|"columns":{
|"id":{"cf":"rowkey", "col":"id", "type":"string"},
|"name":{"cf":"info", "col":"name", "type":"string"},
|"age":{"cf":"info", "col":"age", "type":"string"}
|}
|}""".stripMargin

val spark = SparkSession
.builder()
.appName("HbaseWriteTest")
.getOrCreate()

val df = spark
.read
.options(
Map(
HBaseTableCatalog.tableCatalog -> catalog
)
)
.format("org.apache.spark.sql.execution.datasources.hbase")
.load()

关于apache-spark - spark hbase 连接器 - 异常 "java.lang.UnsupportedOperationException: empty.tail",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42537931/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com