This is an automated email from the ASF dual-hosted git repository.

gortiz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 12060f7770 Support empty strings as json nodes^ (#12555)
12060f7770 is described below

commit 12060f777098ce165c44f8e7805d7a26bfc13681
Author: Gonzalo Ortiz Jaureguizar <[email protected]>
AuthorDate: Tue Mar 5 20:12:40 2024 +0100

    Support empty strings as json nodes^ (#12555)
---
 .../src/main/java/org/apache/pinot/spi/utils/JsonUtils.java      | 4 ++++
 .../src/test/java/org/apache/pinot/spi/utils/JsonUtilsTest.java  | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java 
b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java
index 396c21ad74..392d615570 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/JsonUtils.java
@@ -378,6 +378,10 @@ public class JsonUtils {
       return Collections.emptyList();
     }
 
+    if (node.isMissingNode()) {
+      return Collections.emptyList();
+    }
+
     // Value
     if (node.isValueNode()) {
       String valueAsText = node.asText();
diff --git 
a/pinot-spi/src/test/java/org/apache/pinot/spi/utils/JsonUtilsTest.java 
b/pinot-spi/src/test/java/org/apache/pinot/spi/utils/JsonUtilsTest.java
index 8f425efef9..cf542926d3 100644
--- a/pinot-spi/src/test/java/org/apache/pinot/spi/utils/JsonUtilsTest.java
+++ b/pinot-spi/src/test/java/org/apache/pinot/spi/utils/JsonUtilsTest.java
@@ -632,4 +632,13 @@ public class JsonUtilsTest {
         .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());
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to