yashmayya commented on code in PR #13554: URL: https://github.com/apache/pinot/pull/13554#discussion_r1668217033
########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java: ########## @@ -275,22 +276,17 @@ private String getQueryResponse(String query, @Nullable SqlNode sqlNode, String tableName = _pinotHelixResourceManager.getActualTableName(inputTableName, database); } catch (Exception e) { LOGGER.error("Caught exception while compiling query: {}", query, e); - try { - // try to compile the query using multi-stage engine and suggest using it if it succeeds. - LOGGER.info("Trying to compile query {} using multi-stage engine", query); - QueryEnvironment queryEnvironment = new QueryEnvironment(new TypeFactory(new TypeSystem()), - CalciteSchemaBuilder.asRootSchema(new PinotCatalog(database, _pinotHelixResourceManager.getTableCache()), - database), null, null); - queryEnvironment.getTableNamesForQuery(query); - LOGGER.info("Successfully compiled query using multi-stage engine: {}", query); + + // Check if the query is a v2 supported query + if (ParserUtils.canCompileQueryUsingV2Engine(query, CalciteSchemaBuilder.asRootSchema( + new PinotCatalog(database, _pinotHelixResourceManager.getTableCache()), database))) { return QueryException.getException(QueryException.SQL_PARSING_ERROR, new Exception( - "It seems that the query is only supported by the multi-stage engine, please try it by checking the " - + "\"Use Multi-Stage Engine\" box above")).toString(); - } catch (Exception multipleTablesPassingException) { - LOGGER.error("Caught exception while compiling query using multi-stage engine: {}", - query, multipleTablesPassingException); + "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)")).toString(); + } else { + return QueryException.getException(QueryException.SQL_PARSING_ERROR, e).toString(); } Review Comment: It seemed better to short circuit such requests at the controller rather than unnecessarily sending an additional request to a broker. Also, we validate data access and choose the broker to send the request to based on the table name extracted from the compiled query - https://github.com/apache/pinot/blob/cf1a0f6b9b44fdb567452b63a34e76ac5c635429/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java#L295-L305 In this case, the query compilation itself failed. So, in order to find the right broker to route the request to, we'd need to compile the query using the v2 compiler in any case. -- 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