Skip to content

Commit

Permalink
add null value edge case unit test for Row.equals (#27614)
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-esperanza authored Jul 22, 2023
1 parent 0510dd7 commit 30c324a
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public void testCreateAndCompareNullMap() {
}

@Test
public void testCreateMapWithNullValue() {
public void testCreateAndCompareMapWithNullValue() {
Map<Integer, String> data = new HashMap();
data.put(1, "value1");
data.put(2, "value2");
Expand All @@ -416,6 +416,25 @@ public void testCreateMapWithNullValue() {
.collect(toSchema());
Row row = Row.withSchema(type).addValue(data).build();
assertEquals(data, row.getMap("map"));

Map<Integer, String> onlyNullValueData = new HashMap();
onlyNullValueData.put(1, null);
onlyNullValueData.put(2, null);

Map<Integer, String> otherOnlyNullValueData = new HashMap();
otherOnlyNullValueData.put(3, null);
otherOnlyNullValueData.put(4, null);

Row otherNonNullValue =
Row.withSchema(type)
.addValue(ImmutableMap.of(1, "value1", 2, "value2", 3, "value3", 4, "value4"))
.build();
Row otherNullValue = Row.withSchema(type).addValue(data).build();
Row onlyNullValue = Row.withSchema(type).addValue(onlyNullValueData).build();
Row otherOnlyNullValue = Row.withSchema(type).addValue(otherOnlyNullValueData).build();
assertNotEquals(otherNonNullValue, row);
assertEquals(otherNullValue, row);
assertNotEquals(onlyNullValue, otherOnlyNullValue);
}

@Test
Expand Down

0 comments on commit 30c324a

Please sign in to comment.