siddharthteotia commented on a change in pull request #5483:
URL: https://github.com/apache/incubator-pinot/pull/5483#discussion_r439706205



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/request/context/utils/BrokerRequestToQueryContextConverter.java
##########
@@ -0,0 +1,423 @@
+/**
+ * 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.request.context.utils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.pinot.common.function.AggregationFunctionType;
+import org.apache.pinot.common.function.FunctionDefinitionRegistry;
+import org.apache.pinot.common.request.AggregationInfo;
+import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.request.ExpressionType;
+import org.apache.pinot.common.request.FilterOperator;
+import org.apache.pinot.common.request.GroupBy;
+import org.apache.pinot.common.request.PinotQuery;
+import org.apache.pinot.common.request.Selection;
+import org.apache.pinot.common.request.SelectionSort;
+import org.apache.pinot.common.utils.request.FilterQueryTree;
+import org.apache.pinot.common.utils.request.RequestUtils;
+import org.apache.pinot.core.query.exception.BadQueryRequestException;
+import org.apache.pinot.core.query.request.context.Expression;
+import org.apache.pinot.core.query.request.context.Filter;
+import org.apache.pinot.core.query.request.context.Function;
+import org.apache.pinot.core.query.request.context.OrderByExpression;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.core.query.request.context.predicate.EqPredicate;
+import org.apache.pinot.core.query.request.context.predicate.InPredicate;
+import 
org.apache.pinot.core.query.request.context.predicate.IsNotNullPredicate;
+import org.apache.pinot.core.query.request.context.predicate.IsNullPredicate;
+import org.apache.pinot.core.query.request.context.predicate.NotEqPredicate;
+import org.apache.pinot.core.query.request.context.predicate.NotInPredicate;
+import org.apache.pinot.core.query.request.context.predicate.RangePredicate;
+import 
org.apache.pinot.core.query.request.context.predicate.RegexpLikePredicate;
+import 
org.apache.pinot.core.query.request.context.predicate.TextMatchPredicate;
+import org.apache.pinot.pql.parsers.Pql2Compiler;
+import org.apache.pinot.pql.parsers.pql2.ast.AstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.FilterKind;
+import org.apache.pinot.pql.parsers.pql2.ast.FunctionCallAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.IdentifierAstNode;
+import org.apache.pinot.pql.parsers.pql2.ast.LiteralAstNode;
+
+
+public class BrokerRequestToQueryContextConverter {
+  private BrokerRequestToQueryContextConverter() {
+  }
+
+  private static final Pql2Compiler PQL_COMPILER = new Pql2Compiler();
+
+  /**
+   * Converts the given BrokerRequest to a QueryContext.
+   * <p>Use PinotQuery if available to avoid the unnecessary parsing of the 
expression.
+   * <p>TODO: We cannot use PinotQuery to generate the {@code filter} because 
{@code BrokerRequestOptimizer} only
+   *          optimizes the BrokerRequest but not the PinotQuery.
+   */
+  public static QueryContext convertToQueryContext(BrokerRequest 
brokerRequest) {
+    PinotQuery pinotQuery = brokerRequest.getPinotQuery();
+
+    List<Expression> selectExpressions;
+    Map<Expression, String> aliasMap;
+    List<Expression> groupByExpressions = null;
+    int limit;
+    int offset = 0;
+    if (pinotQuery != null) {
+      aliasMap = new HashMap<>();
+      List<org.apache.pinot.common.request.Expression> selectList = 
pinotQuery.getSelectList();
+      int numExpressions = selectList.size();

Review comment:
       I would highly suggest to use a different suffix otherwise we will end 
up using these package absolute references in this class since this is 
referring to both query context pojos as well as their thrift counterparts. 
   
   May be choose "info" as the suffix. For the predicate classes that are 
duplicated, are we going to delete them at some point. I think we need to after 
query engine starts using predicate from the context. So may be until then 
let's keep a different name and then start using a suitable names once existing 
classes are deleted. 
   
   I am not good with names so "info" is the suffix that comes to mind. 




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

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