ankitsultana commented on code in PR #14048: URL: https://github.com/apache/pinot/pull/14048#discussion_r1772521850
########## pinot-plugins/pinot-timeseries-lang/pinot-timeseries-m3ql/src/main/java/org/apache/pinot/tsdb/m3ql/M3TimeSeriesPlanner.java: ########## @@ -0,0 +1,158 @@ +/** + * 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.tsdb.m3ql; + +import com.google.common.base.Preconditions; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.pinot.tsdb.m3ql.parser.Tokenizer; +import org.apache.pinot.tsdb.m3ql.plan.KeepLastValuePlanNode; +import org.apache.pinot.tsdb.m3ql.plan.TransformNullPlanNode; +import org.apache.pinot.tsdb.m3ql.time.TimeBucketComputer; +import org.apache.pinot.tsdb.spi.AggInfo; +import org.apache.pinot.tsdb.spi.RangeTimeSeriesRequest; +import org.apache.pinot.tsdb.spi.TimeBuckets; +import org.apache.pinot.tsdb.spi.TimeSeriesLogicalPlanResult; +import org.apache.pinot.tsdb.spi.TimeSeriesLogicalPlanner; +import org.apache.pinot.tsdb.spi.plan.BaseTimeSeriesPlanNode; +import org.apache.pinot.tsdb.spi.plan.ScanFilterAndProjectPlanNode; + + +public class M3TimeSeriesPlanner implements TimeSeriesLogicalPlanner { + @Override + public void init(Map<String, Object> config) { + } + + @Override + public TimeSeriesLogicalPlanResult plan(RangeTimeSeriesRequest request) { + if (!request.getLanguage().equals(Constants.LANGUAGE)) { + throw new IllegalArgumentException(String.format("Invalid engine id: %s. Expected: %s", request.getLanguage(), + Constants.LANGUAGE)); + } + // Step-1: Parse and create a logical plan tree. + BaseTimeSeriesPlanNode planNode = planQuery(request); + // Step-2: Compute the time-buckets. + TimeBuckets timeBuckets = TimeBucketComputer.compute(planNode, request); + return new TimeSeriesLogicalPlanResult(planNode, timeBuckets); + } + + public BaseTimeSeriesPlanNode planQuery(RangeTimeSeriesRequest request) { + PlanIdGenerator planIdGenerator = new PlanIdGenerator(); + Tokenizer tokenizer = new Tokenizer(request.getQuery()); + List<List<String>> commands = tokenizer.tokenize(); + Preconditions.checkState(commands.size() > 1, "At least two commands required. " + + "Query should start with a fetch followed by an aggregation."); + BaseTimeSeriesPlanNode lastNode = null; + AggInfo aggInfo = null; + List<String> groupByColumns = new ArrayList<>(); + BaseTimeSeriesPlanNode rootNode = null; + for (int commandId = commands.size() - 1; commandId >= 0; commandId--) { Review Comment: Yeah I am running a proper JavaCC based parser internally. I need to go through a few reviews internally first before adding that implementation in OSS, so for now I added this dummy implementation. I'll rewrite the entire m3ql plugin in follow-up PRs in the next few weeks. -- 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