vrajat commented on code in PR #15046:
URL: https://github.com/apache/pinot/pull/15046#discussion_r1953766412


##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java:
##########
@@ -299,601 +299,609 @@ protected BrokerResponse handleRequest(long requestId, 
String query, SqlNodeAndO
     Tracing.ThreadAccountantOps.setupRunner(String.valueOf(requestId));
 
     try {
-      // Compile the request into PinotQuery
-      long compilationStartTimeNs = System.nanoTime();
-      PinotQuery pinotQuery;
-      try {
-        pinotQuery = CalciteSqlParser.compileToPinotQuery(sqlNodeAndOptions);
-      } catch (Exception e) {
-        LOGGER.info("Caught exception while compiling SQL request {}: {}, {}", 
requestId, query, e.getMessage());
-        
_brokerMetrics.addMeteredGlobalValue(BrokerMeter.REQUEST_COMPILATION_EXCEPTIONS,
 1);
-        requestContext.setErrorCode(QueryException.SQL_PARSING_ERROR_CODE);
-        // Check if the query is a v2 supported query
-        String database = 
DatabaseUtils.extractDatabaseFromQueryRequest(sqlNodeAndOptions.getOptions(), 
httpHeaders);
-        if (ParserUtils.canCompileWithMultiStageEngine(query, database, 
_tableCache)) {
-          return new 
BrokerResponseNative(QueryException.getException(QueryException.SQL_PARSING_ERROR,
 new Exception(
-              "It seems that the query is only supported by the multi-stage 
query engine, please retry the query using "
-                  + "the multi-stage query engine "
-                  + 
"(https://docs.pinot.apache.org/developers/advanced/v2-multi-stage-query-engine)")));
-        } else {
-          return new 
BrokerResponseNative(QueryException.getException(QueryException.SQL_PARSING_ERROR,
 e));
-        }
-      }
-
-      if (isDefaultQueryResponseLimitEnabled() && !pinotQuery.isSetLimit()) {
-        pinotQuery.setLimit(_defaultQueryLimit);
-      }
+      return handleRequestImpl(requestId, query, sqlNodeAndOptions, request, 
requesterIdentity, requestContext,
+          httpHeaders, accessControl);
+    } finally {
+      Tracing.ThreadAccountantOps.clear();
+    }
+  }
 
-      if (isLiteralOnlyQuery(pinotQuery)) {
-        LOGGER.debug("Request {} contains only Literal, skipping server query: 
{}", requestId, query);
-        try {
-          if (pinotQuery.isExplain()) {
-            // EXPLAIN PLAN results to show that query is evaluated 
exclusively by Broker.
-            return BrokerResponseNative.BROKER_ONLY_EXPLAIN_PLAN_OUTPUT;
-          }
-          return processLiteralOnlyQuery(requestId, pinotQuery, 
requestContext);
-        } catch (Exception e) {
-          // TODO: refine the exceptions here to early termination the queries 
won't requires to send to servers.
-          LOGGER.warn("Unable to execute literal request {}: {} at broker, 
fallback to server query. {}", requestId,
-              query, e.getMessage());
-        }
+  protected BrokerResponse handleRequestImpl(long requestId, String query, 
SqlNodeAndOptions sqlNodeAndOptions,

Review Comment:
   Done



##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OOMProtectionIntegrationTest.java:
##########
@@ -0,0 +1,110 @@
+/**
+ * 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.integration.tests;
+
+import java.io.File;
+import java.util.List;
+import org.apache.pinot.spi.config.instance.InstanceType;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.apache.pinot.util.TestUtils;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+public class OOMProtectionIntegrationTest extends 
BaseClusterIntegrationTestSet {

Review Comment:
   Done



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