Skip to content

Commit

Permalink
[SPARK-130] MapRDB connector - NPE while saving Pair RDD with 'null' …
Browse files Browse the repository at this point in the history
…values (apache#312)
  • Loading branch information
avovchenko authored and ekrivokonmapr committed Sep 19, 2019
1 parent 32423bf commit 4605534
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ private[spark] case class PairedDocumentRDDFunctions[K, V](rdd: RDD[(K, V)])(
Writer.initialize(tableName, cnf.value, isnewAndBulkLoad, true)
while (iter.hasNext) {
val element = iter.next
checkElementForNull(element)
f.write(v.getValue(element._2), f.getValue(element._1), writer)
}
writer.close()
Expand All @@ -183,10 +184,18 @@ private[spark] case class PairedDocumentRDDFunctions[K, V](rdd: RDD[(K, V)])(
Writer.initialize(tablename, cnf.value, isnewAndBulkLoad, false)
while (iter.hasNext) {
val element = iter.next
checkElementForNull(element)
f.write(v.getValue(element._2), f.getValue(element._1), writer)
}
writer.close()
}
)
}

def checkElementForNull(element: (K, V)): Boolean = {
if (element._1 == null || element._2 == null) {
throw new IllegalArgumentException("Key/Value cannot be null")
}
true
}
}

0 comments on commit 4605534

Please sign in to comment.