From 6a622b071fdf2e86e1849a4473cf9525e2ae3de0 Mon Sep 17 00:00:00 2001 From: Weiqing Yang Date: Fri, 26 May 2017 21:27:42 -0700 Subject: [PATCH] [SPARK-6628][SQL][Branch-2.1] Fix ClassCastException when executing sql statement 'insert into' on hbase table --- .../org/apache/spark/sql/hive/hiveWriterContainers.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveWriterContainers.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveWriterContainers.scala index 16cfa9d1cc5c..a0c0d9a33852 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveWriterContainers.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveWriterContainers.scala @@ -78,8 +78,11 @@ private[hive] class SparkHiveWriterContainer( @transient protected lazy val committer = conf.value.getOutputCommitter @transient protected lazy val jobContext = new JobContextImpl(conf.value, jID.value) @transient private lazy val taskContext = new TaskAttemptContextImpl(conf.value, taID.value) - @transient private lazy val outputFormat = - conf.value.getOutputFormat.asInstanceOf[HiveOutputFormat[AnyRef, Writable]] + @transient private lazy val outputFormat = conf.value.getOutputFormat match { + case format: HiveOutputFormat[AnyRef, Writable] + => format.asInstanceOf[HiveOutputFormat[AnyRef, Writable]] + case _ => null + } def driverSideSetup() { setIDs(0, 0, 0)