satishd commented on code in PR #12437:
URL: https://github.com/apache/pinot/pull/12437#discussion_r1515463808


##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java:
##########
@@ -597,6 +596,39 @@ public static String splitPart(String input, String 
delimiter, int index) {
     }
   }
 
+  /**
+   * @param input the input String to be split into parts.
+   * @param delimiter the specified delimiter to split the input string.
+   * @param index the specified index for the splitted parts to be returned.
+   * @param max the max count of parts that the input string can be splitted 
into.
+   * @return splits string on the delimiter with the limit count and returns 
String at specified index from the split.

Review Comment:
   Currently, the argument name is `max` which is inconsistent with the javadoc 
here that uses `limit`. The [existing 
method](https://github.com/apache/pinot/blob/master/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java#L579)
 uses `limit` and we can continue using the same instead of `max` and leave 
with the existing comment.  



##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java:
##########
@@ -597,6 +596,39 @@ public static String splitPart(String input, String 
delimiter, int index) {
     }
   }
 
+  /**
+   * @param input the input String to be split into parts.
+   * @param delimiter the specified delimiter to split the input string.
+   * @param index the specified index for the splitted parts to be returned.
+   * @param max the max count of parts that the input string can be splitted 
into.
+   * @return splits string on the delimiter with the limit count and returns 
String at specified index from the split.
+   */
+  @ScalarFunction
+  public static String splitPart(String input, String delimiter, int index, 
int max) {
+    String[] splitString = StringUtils.splitByWholeSeparator(input, delimiter, 
max);
+    if (index < splitString.length) {
+      return splitString[index];
+    } else {
+      return "null";
+    }
+  }
+
+  /**
+   * @param input the input String to be split into parts.
+   * @param delimiter the specified delimiter to split the input string.
+   * @param index the specified index for the splitted parts to be returned.
+   * @return splits string on the delimiter with the limit count and returns 
String at specified index from the split.

Review Comment:
   There is no `limit` here to split with the delimiter. Please update the 
comment. 



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