【原創】大叔問題定位分享(16)spark寫數據到hive外部表報錯ClassCastException: org.apache.hadoop.hive.hbase.HiveHBaseTableOutputFormat cannot be cast to org.apache.hadoop.hive.ql.io.HiveOutputFormat


 spark 2.1.1

 

spark在寫數據到hive外部表(底層數據在hbase中)時會報錯

Caused by: java.lang.ClassCastException: org.apache.hadoop.hive.hbase.HiveHBaseTableOutputFormat cannot be cast to org.apache.hadoop.hive.ql.io.HiveOutputFormat
at org.apache.spark.sql.hive.SparkHiveWriterContainer.outputFormat$lzycompute(hiveWriterContainers.scala:82)

 

org.apache.spark.sql.hive.SparkHiveWriterContainer

org.apache.spark.sql.hive.SparkHiveWriterContainer
  @transient private lazy val outputFormat = conf.value.getOutputFormat.asInstanceOf[HiveOutputFormat[AnyRef, Writable]]

 

報錯的是這一句,查看代碼發現此時這個變量並沒有什么用處,可以在不能cast時置為null

  @transient private lazy val outputFormat =
    // conf.value.getOutputFormat.asInstanceOf[HiveOutputFormat[AnyRef, Writable]]
    conf.value.getOutputFormat match {
      case format if format.isInstanceOf[HiveOutputFormat[AnyRef, Writable]] => format.asInstanceOf[HiveOutputFormat[AnyRef, Writable]]
      case _ => null
    }

問題解決,官方討論如下: https://issues.apache.org/jira/browse/SPARK-6628

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM