Skip to content

Commit

Permalink
Support empty strings as json nodes^ (#12555)
Browse files Browse the repository at this point in the history
  • Loading branch information
gortiz authored Mar 5, 2024
1 parent fc776e7 commit 12060f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ private static List<Map<String, String>> flatten(JsonNode node, JsonIndexConfig
return Collections.emptyList();
}

if (node.isMissingNode()) {
return Collections.emptyList();
}

// Value
if (node.isValueNode()) {
String valueAsText = node.asText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,4 +632,13 @@ public void testInferSchema()
.addDateTime("hoursSinceEpoch", FieldSpec.DataType.INT, "1:HOURS:EPOCH", "1:HOURS").build();
Assert.assertEquals(inferredPinotSchema, expectedSchema);
}

@Test
public void testEmptyString()
throws IOException {
JsonIndexConfig jsonIndexConfig = new JsonIndexConfig();
JsonNode jsonNode = JsonUtils.stringToJsonNode("");
List<Map<String, String>> flattenedRecords = JsonUtils.flatten(jsonNode, jsonIndexConfig);
assertTrue(flattenedRecords.isEmpty());
}
}

0 comments on commit 12060f7

Please sign in to comment.