dario-liberman commented on code in PR #11092: URL: https://github.com/apache/pinot/pull/11092#discussion_r1272733046
########## pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/FunnelCountAggregationFunction.java: ########## @@ -239,48 +350,112 @@ Optional<ExpressionContext> find(List<ExpressionContext> expressions) { public List<ExpressionContext> getInputExpressions(List<ExpressionContext> expressions) { return this.find(expressions).map(exp -> exp.getFunction().getArguments()) - .orElseThrow(() -> new IllegalStateException("FUNNELCOUNT requires " + _name)); + .orElseThrow(() -> new IllegalArgumentException("FUNNELCOUNT requires " + _name)); } public ExpressionContext getFirstInputExpression(List<ExpressionContext> expressions) { return this.find(expressions) .flatMap(exp -> exp.getFunction().getArguments().stream().findFirst()) - .orElseThrow(() -> new IllegalStateException("FUNNELCOUNT: " + _name + " requires an argument.")); + .orElseThrow(() -> new IllegalArgumentException("FUNNELCOUNT: " + _name + " requires an argument.")); + } + + public List<String> getLiterals(List<ExpressionContext> expressions) { + List<ExpressionContext> inputExpressions = find(expressions).map(exp -> exp.getFunction().getArguments()) + .orElseGet(Collections::emptyList); + Preconditions.checkArgument( + inputExpressions.stream().allMatch(exp -> exp.getType() == ExpressionContext.Type.LITERAL), + "FUNNELCOUNT: " + _name + " parameters must be literals"); + return inputExpressions.stream().map(exp -> exp.getLiteral().getStringValue()).collect(Collectors.toList()); + } + + public static void validate(List<ExpressionContext> expressions) { + final List<String> invalidOptions = expressions.stream() + .filter(expression -> !Arrays.stream(Option.values()).anyMatch(option -> option.matches(expression))) + .map(ExpressionContext::toString) + .collect(Collectors.toList()); + + if (!invalidOptions.isEmpty()) { + throw new IllegalArgumentException("Invalid FUNNELCOUNT options: " + String.join(", ", invalidOptions)); + } + } + } + + enum Setting { + SET("set"), + BITMAP("bitmap"), Review Comment: As I say above, a challenge is that of sorted vs unsorted segments. But I can probably reduce the runtime choice to just two strategies: sorted and unsorted strategy; with the unsorted one being resolved at construction time depending on the strategy settings given. -- 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