Skip to content

Commit

Permalink
UniqueKeyHashedRelation.get should return null if the value is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Oct 9, 2014
1 parent e0ebdd1 commit 4b9d0c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ private[joins] final class GeneralHashedRelation(hashTable: JavaHashMap[Row, Com
final class UniqueKeyHashedRelation(hashTable: JavaHashMap[Row, Row])
extends HashedRelation with Serializable {

override def get(key: Row) = CompactBuffer(hashTable.get(key))
override def get(key: Row) = {
val v = hashTable.get(key)
if (v eq null) null else CompactBuffer(v)
}

def getValue(key: Row): Row = hashTable.get(key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HashedRelationSuite extends FunSuite {

assert(hashed.get(data(0)) == CompactBuffer[Row](data(0)))
assert(hashed.get(data(1)) == CompactBuffer[Row](data(1)))
assert(hashed.get(Row(10)) === null)

val data2 = CompactBuffer[Row](data(2))
data2 += data(2)
Expand All @@ -51,10 +52,12 @@ class HashedRelationSuite extends FunSuite {
assert(hashed.get(data(0)) == CompactBuffer[Row](data(0)))
assert(hashed.get(data(1)) == CompactBuffer[Row](data(1)))
assert(hashed.get(data(2)) == CompactBuffer[Row](data(2)))
assert(hashed.get(Row(10)) === null)

val uniqHashed = hashed.asInstanceOf[UniqueKeyHashedRelation]
assert(uniqHashed.getValue(data(0)) == data(0))
assert(uniqHashed.getValue(data(1)) == data(1))
assert(uniqHashed.getValue(data(2)) == data(2))
assert(uniqHashed.getValue(Row(10)) == null)
}
}

0 comments on commit 4b9d0c9

Please sign in to comment.