gortiz commented on code in PR #14951:
URL: https://github.com/apache/pinot/pull/14951#discussion_r1942634833
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java:
##########
@@ -210,51 +217,62 @@ private String getMultiStageQueryResponse(String query,
String queryOptions, Htt
queryOptionsMap.putAll(RequestUtils.getOptionsFromString(queryOptions));
}
String database =
DatabaseUtils.extractDatabaseFromQueryRequest(queryOptionsMap, httpHeaders);
+ List<String> tableNames = getTableNames(query, database);
+ List<String> instanceIds = getInstanceIds(query, tableNames, database);
+ String instanceId = selectRandomInstanceId(instanceIds);
+ return sendRequestToBroker(query, instanceId, traceEnabled, queryOptions,
httpHeaders);
+ }
+
+ private List<String> getTableNames(String query, String database) {
QueryEnvironment queryEnvironment =
new QueryEnvironment(database,
_pinotHelixResourceManager.getTableCache(), null);
List<String> tableNames;
try {
tableNames = queryEnvironment.getTableNamesForQuery(query);
+ } catch (QException e) {
+ if (e.getErrorCode() != QueryException.UNKNOWN_ERROR_CODE) {
+ throw e;
+ } else {
+ throw new QException(QException.SQL_PARSING_ERROR_CODE, e);
+ }
} catch (Exception e) {
- return QueryException.getException(QueryException.SQL_PARSING_ERROR,
- new Exception("Unable to find table for this query", e)).toString();
+ throw new QException(QException.SQL_PARSING_ERROR_CODE, e);
Review Comment:
Because we assume other error types will be more precise. The error codes
being used are pretty chaotic. It looks like we added them without actual
consideration and the fact that we cannot create hierarchies is not a good
design. For example, is a UNKNOWN_COLUMN_ERROR_CODE a
QUERY_VALIDATION_ERROR_CODE?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]