Jackie-Jiang commented on code in PR #14434:
URL: https://github.com/apache/pinot/pull/14434#discussion_r1841323394


##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/funnel/window/FunnelBaseAggregationFunction.java:
##########
@@ -58,12 +62,25 @@ public 
FunnelBaseAggregationFunction(List<ExpressionContext> arguments) {
     Preconditions.checkArgument(numArguments >= 3 + _numSteps,
         "FUNNEL_AGG_FUNC expects >= " + (3 + _numSteps) + " arguments, got: 
%s. The function can be used as "
             + getType().getName() + "(timestampExpression, windowSize, 
numberSteps, stepExpression, "
-            + "[stepExpression, ..], [mode, [mode, ... ]])",
+            + "[stepExpression, ..], [extraArgument/mode, [extraArgument/mode, 
... ]])",
         numArguments);
     _stepExpressions = arguments.subList(3, 3 + _numSteps);
-    if (numArguments > 3 + _numSteps) {
-      arguments.subList(3 + _numSteps, numArguments)
-          .forEach(arg -> 
_modes.add(Mode.valueOf(arg.getLiteral().getStringValue().toUpperCase())));
+    for (int i = 3 + _numSteps; i < numArguments; i++) {
+      String extraArgument = 
arguments.get(i).getLiteral().getStringValue().toUpperCase();
+      String[] parsedExtraArguments = extraArgument.split("=");
+      if (parsedExtraArguments.length == 2) {
+        String key = parsedExtraArguments[0];
+        if (key.equalsIgnoreCase("MaxStepDuration")) {
+          _maxStepDuration = Long.parseLong(parsedExtraArguments[1]);
+          Preconditions.checkArgument(_maxStepDuration > 0, "MaxStepDuration 
must be > 0");
+        }
+        continue;
+      }
+      try {
+        _modes.add(Mode.valueOf(extraArgument));
+      } catch (Exception e) {
+        LOGGER.error("Unrecognized extra argument for funnel function: {}", 
extraArgument);

Review Comment:
   We should throw the exception out for invalid arguments



##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/funnel/window/FunnelBaseAggregationFunction.java:
##########
@@ -58,12 +62,25 @@ public 
FunnelBaseAggregationFunction(List<ExpressionContext> arguments) {
     Preconditions.checkArgument(numArguments >= 3 + _numSteps,
         "FUNNEL_AGG_FUNC expects >= " + (3 + _numSteps) + " arguments, got: 
%s. The function can be used as "
             + getType().getName() + "(timestampExpression, windowSize, 
numberSteps, stepExpression, "
-            + "[stepExpression, ..], [mode, [mode, ... ]])",
+            + "[stepExpression, ..], [extraArgument/mode, [extraArgument/mode, 
... ]])",
         numArguments);
     _stepExpressions = arguments.subList(3, 3 + _numSteps);
-    if (numArguments > 3 + _numSteps) {
-      arguments.subList(3 + _numSteps, numArguments)
-          .forEach(arg -> 
_modes.add(Mode.valueOf(arg.getLiteral().getStringValue().toUpperCase())));
+    for (int i = 3 + _numSteps; i < numArguments; i++) {
+      String extraArgument = 
arguments.get(i).getLiteral().getStringValue().toUpperCase();
+      String[] parsedExtraArguments = extraArgument.split("=");
+      if (parsedExtraArguments.length == 2) {
+        String key = parsedExtraArguments[0];
+        if (key.equalsIgnoreCase("MaxStepDuration")) {

Review Comment:
   Consider also allowing `mode=<mode>` as argument for consistency?



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