siddharthteotia commented on a change in pull request #6490:
URL: https://github.com/apache/incubator-pinot/pull/6490#discussion_r564874873



##########
File path: 
pinot-common/src/test/java/org/apache/pinot/common/function/JsonFunctionsTest.java
##########
@@ -65,4 +65,42 @@ public void testJsonFunction()
     assertEquals(JsonFunctions.jsonPathDouble(jsonString, "$.actor.aaa", 
53.2), 53.2);
   }
 
+  @Test
+  public void testJsonFunctionExtractingArray()
+      throws JsonProcessingException {
+    String jsonString = "{\n" +
+        "    \"name\": \"Pete\",\n" +
+        "    \"age\": 24,\n" +
+        "    \"subjects\": [\n" +
+        "        {\n" +
+        "            \"name\": \"maths\",\n" +
+        "        \"grade\": \"A\"\n" +
+        "        },\n" +
+        "        {\n" +
+        "            \"name\": \"maths\",\n" +
+        "        \"grade\": \"B\"\n" +
+        "        }\n" +
+        "    ]\n" +
+        "}";
+    assertEquals(JsonFunctions.jsonPathArray(jsonString, 
"$.subjects[*].name"), new String[]{"maths", "maths"});
+    assertEquals(JsonFunctions.jsonPathArray(jsonString, 
"$.subjects[*].grade"), new String[]{"A", "B"});
+  }
+
+  @Test
+  public void testJsonFunctionOnJsonArray()
+      throws JsonProcessingException {
+    String jsonArrayString =
+        "[\n" +
+        "        {\n" +
+        "            \"name\": \"maths\",\n" +
+        "        \"grade\": \"A\"\n" +
+        "        },\n" +

Review comment:
       Also, scalar functions should also have e2e query execution unit tests. 
Alternatively, may be add a query compilation unit test as well to ensure it 
gets recognized/compiled as scalar




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to