walterddr commented on code in PR #10336: URL: https://github.com/apache/pinot/pull/10336#discussion_r1132824868
########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java: ########## @@ -170,10 +171,20 @@ private String getMultiStageQueryResponse(String query, String queryOptions, Htt return QueryException.ACCESS_DENIED_ERROR.toString(); } - // Get brokers, only DEFAULT tenant is supported for now. - // TODO: implement logic that only allows executing query where all accessed tables are within the same tenant. - List<String> instanceIds = new ArrayList<>(_pinotHelixResourceManager.getAllInstancesForBrokerTenant( - TagNameUtils.DEFAULT_TENANT_NAME)); + SqlNodeAndOptions sqlNodeAndOptions = RequestUtils.parseQuery(query); + List<String> tableNames = CalciteSqlParser.extractTableNamesFromNode(sqlNodeAndOptions.getSqlNode()); + if (tableNames.size() == 0) { + return QueryException.SQL_PARSING_ERROR.toString(); + } + + String brokerTenant = getCommonBrokerTenant(tableNames); + String serverTenant = getCommonServerTenant(tableNames); + if (brokerTenant == null || serverTenant == null) { + return QueryException.getException(QueryException.BROKER_REQUEST_SEND_ERROR, + new Exception("Unable to dispatch multistage query with multiple tables on different tenant")).toString(); Review Comment: can you attach the `tableNames` in the error message to make it more informative? -- 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