jihoonson opened a new pull request #10746: URL: https://github.com/apache/druid/pull/10746
### Description Druid querying system returns an HTTP status code on query failures. Currently, most of query failures return an internal error (500) which could be misleading in some cases. This PR is to tidy up this and return a proper status code. Here is a list of query errors, their current status codes, and proposed changes. #### Query planning errors Exception | Description| Current code | Proposed new code ------------ | ------------- | ------------- | ------------- SqlParseException and ValidationException from Calcite | Query planning failed | 500 | **400** CannotPlanException from Calcite | Failed to find the best plan. Likely an internal error | 500 | RelConversionException from Calcite | Conversion from SQL to Druid failed | 500 | CannotBuildQueryException | Failed to create a Druid native query from DruidRel. Likely an internal error | 500 | Others | Unknown errors | 500 | #### Query execution errors Exception | Description| Current code | Proposed new code ------------ | ------------- | ------------- | ------------- QueryTimeoutException | Query execution didn't finish in timeout | 504 | Unauthorized exception | Authentication failed to execute the query | 401 | ForbiddenException | Authorization failed to execute the query | 403 | QueryCapacityExceededException | Query failed to schedule because of the lack of resources available at the time when the query was submitted | 429 | ResourceLimitExceededException | Query asked more resources than configured threshold | 500 | **400** InsufficientResourceException | Query failed to schedule because of lack of merge buffers available at the time when it was submitted | 500 | **429**, merged to QueryCapacityExceededException QueryUnsupportedException | Unsupported functionality | 400 | **501** Others | Unknown exceptions | 500 | `BadQueryException` is added to represent all kinds of query exceptions that should return 400. <hr> This PR has: - [x] been self-reviewed. - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.) - [ ] added documentation for new or modified features or behaviors. - [x] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links. - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml) - [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader. - [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met. - [ ] added integration tests. - [ ] been tested in a test Druid cluster. <hr> ##### Key changed/added classes in this PR * `BadQueryException` * `ResourceLimitExceededException` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org