Jackie-Jiang commented on code in PR #15046: URL: https://github.com/apache/pinot/pull/15046#discussion_r1953295349
########## 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: (minor) We usually name the actual impl method as `doHandleRequest()` -- 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