xiangfu0 commented on code in PR #13176: URL: https://github.com/apache/pinot/pull/13176#discussion_r1608327042
########## pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/funnel/FunnelMaxStepAggregationFunction.java: ########## @@ -0,0 +1,302 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.core.query.aggregation.function.funnel; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.pinot.common.request.context.ExpressionContext; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.core.common.BlockValSet; +import org.apache.pinot.core.query.aggregation.AggregationResultHolder; +import org.apache.pinot.core.query.aggregation.ObjectAggregationResultHolder; +import org.apache.pinot.core.query.aggregation.function.AggregationFunction; +import org.apache.pinot.core.query.aggregation.groupby.GroupByResultHolder; +import org.apache.pinot.core.query.aggregation.groupby.ObjectGroupByResultHolder; +import org.apache.pinot.segment.spi.AggregationFunctionType; + + +public class FunnelMaxStepAggregationFunction + implements AggregationFunction<PriorityQueue<FunnelStepEvent>, Long> { + private final ExpressionContext _timestampExpression; + private final long _windowSize; + private final List<ExpressionContext> _stepExpressions; + private final Set<Mode> _modes = new HashSet<>(); + private final int _numSteps; + + public FunnelMaxStepAggregationFunction(List<ExpressionContext> arguments) { + int numArguments = arguments.size(); + Preconditions.checkArgument(numArguments > 2, + "FUNNELMAXSTEP expects >= 3 arguments, got: %s. The function can be used as " + + "funnelMaxStep(timestampExpression, windowSize, ARRAY[stepExpression, ..], [mode, [mode, ... ]])", + numArguments); + _timestampExpression = arguments.get(0); + _windowSize = arguments.get(1).getLiteral().getLongValue(); + Preconditions.checkArgument(_windowSize > 0, "Window size must be > 0"); + ExpressionContext stepExpressionContext = arguments.get(2); + if (stepExpressionContext.getFunction() != null) { + // LEAF stage init this function like funnelmaxstep($1,'1000',arrayValueConstructor($2,$3,$4,...)) + _stepExpressions = stepExpressionContext.getFunction().getArguments(); + } else { + // Intermediate Stage init this function like funnelmaxstep($1,'1000',__PLACEHOLDER__) Review Comment: The issue is that `stepExpressionContext` is modeled as an array function of multiple expressions. But the intermediate stage fills it with a literal `__PLACEHOLDER__`, not a function. -- 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]
