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



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java
##########
@@ -328,14 +329,27 @@ public static String normalize(String input) {
 
   /**
    * see Normalizer#normalize(String, Form)
-   * @param input
-   * @param form
-   * @return transforms string with the specified normalization form
    */
-  @ScalarFunction
-  public static String normalize(String input, String form) {
-    Normalizer.Form targetForm = Normalizer.Form.valueOf(form);
-    return Normalizer.normalize(input, targetForm);
+  public static class NormalizeFunction implements InitializableScalarFunction 
{
+    private Normalizer.Form _form;
+
+    @Override
+    public void init(Object... arguments) {
+      Preconditions.checkState(arguments.length == 2
+          && arguments[1] instanceof String);
+      _form = Normalizer.Form.valueOf((String) arguments[1]);
+    }
+
+    /**
+     * see Normalizer#normalize(String, Form)
+     * @param input
+     * @param form
+     * @return transforms string with the specified normalization form
+     */
+    @ScalarFunction
+    String normalize(String input, String form) {

Review comment:
       There are other callers to `FunctionInvoker.invoke()`, and we need to 
make sure all of them call `init()` first




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to