Jackie-Jiang commented on a change in pull request #7819:
URL: https://github.com/apache/pinot/pull/7819#discussion_r795992164



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java
##########
@@ -103,11 +104,13 @@ public static Object jsonPath(Object object, String 
jsonPath) {
 
   @ScalarFunction
   public static Object[] jsonPathArrayDefaultEmpty(Object object, String 
jsonPath) {
-    try {
-      return jsonPathArray(object, jsonPath);
-    } catch (Exception e) {
-      return new Object[0];
+    final Object value;

Review comment:
       (minor) After fixing `jsonPathArray()`, this method can be simplified by 
checking the return value of `jsonPathArray()`

##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java
##########
@@ -93,8 +95,7 @@ public static Object jsonPath(Object object, String jsonPath) 
{
    * Extract object array based on Json path
    */
   @ScalarFunction
-  public static Object[] jsonPathArray(Object object, String jsonPath)
-      throws JsonProcessingException {
+  public static Object[] jsonPathArray(Object object, String jsonPath) {
     if (object instanceof String) {
       return convertObjectToArray(PARSE_CONTEXT.parse((String) 
object).read(jsonPath, NO_PREDICATES));

Review comment:
       We should check return value before calling `convertObjectToArray()`. 
Currently it will return `new Object[] {null}` which is incorrect

##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java
##########
@@ -103,11 +104,13 @@ public static Object jsonPath(Object object, String 
jsonPath) {
 
   @ScalarFunction
   public static Object[] jsonPathArrayDefaultEmpty(Object object, String 
jsonPath) {
-    try {
-      return jsonPathArray(object, jsonPath);
-    } catch (Exception e) {
-      return new Object[0];
+    final Object value;

Review comment:
       (minor) We don't usually put `final` for local variable. Since you are 
changing it, let's remove the `final`




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

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