HBASE-21841 Allow inserting null values throw DataSource API
authorBalazs Meszaros <balazs.meszaros@cloudera.com>
Mon, 4 Feb 2019 14:14:52 +0000 (15:14 +0100)
committerPeter Somogyi <petersomogyi@users.noreply.github.com>
Tue, 12 Feb 2019 13:17:07 +0000 (14:17 +0100)
spark/hbase-spark/src/main/scala/org/apache/hadoop/hbase/spark/DefaultSource.scala

index 4e05695..d9d5a66 100644 (file)
@@ -222,8 +222,11 @@ case class HBaseRelation (
       val put = timestamp.fold(new Put(rBytes))(new Put(rBytes, _))
 
       colsIdxedFields.foreach { case (x, y) =>
-        val b = Utils.toBytes(row(x), y)
-        put.addColumn(Bytes.toBytes(y.cf), Bytes.toBytes(y.col), b)
+        val r = row(x)
+        if (r != null) {
+          val b = Utils.toBytes(r, y)
+          put.addColumn(Bytes.toBytes(y.cf), Bytes.toBytes(y.col), b)
+        }
       }
       count += 1
       (new ImmutableBytesWritable, put)