You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/03/22 21:42:20 UTC

[GitHub] [pinot] richardstartin commented on a change in pull request #8382: builtin datetime functions to avoid throwing NullPointerException when input value is null

richardstartin commented on a change in pull request #8382:
URL: https://github.com/apache/pinot/pull/8382#discussion_r832652223



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/FunctionInvoker.java
##########
@@ -131,4 +133,19 @@ public Object invoke(Object[] arguments) {
           "Caught exception while invoking method: " + _method + " with arguments: " + Arrays.toString(arguments), e);
     }
   }
+
+  /**
+   * Whether method is a scalar function with nullableParameters property set to true.
+   */
+  public boolean hasNullableParameters() {
+    for (final Annotation annotation : _method.getAnnotations()) {
+      if (annotation.annotationType().equals(ScalarFunction.class)) {
+        final ScalarFunction scalarFunctionAnnotation = (ScalarFunction) annotation;
+        if (scalarFunctionAnnotation.nullableParameters()) {
+          return true;
+        }
+      }
+    }
+    return false;

Review comment:
       I think the following would be cleaner (and probably more efficient)
   ```java
   return _method.isAnnotationPresent(ScalarFunction.class) && _method.getAnnotation(ScalarFunction.class).nullableParameters();
   ```




-- 
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-unsubscribe@pinot.apache.org

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



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