FrankChen021 opened a new pull request, #13022:
URL: https://github.com/apache/druid/pull/13022

   The problem was first reported by #12760 , and #12833 solves that specific 
issue.
   This PR solves all potential problems by providing a group of type safe 
methods.
   
   
   ### Description
   
   `QueryContext` holds values passed from user side in JSON format. 
   And currently Druid requires values in JSON must be strictly type matched. 
   For example, a property `maxOnDiskStorage` in Druid is defined as integer, 
it must be in the format as 
   
   ```json
   "context": {"maxOnDiskStorage": 100} 
   ```
   
   If the number 100 is serialized as string as 
   
   ```json
   "context": {"maxOnDiskStorage": "100"} 
   ```
   
   Druid throws a `ClassCastException` to reject the input query.
   
   
   Actually, string-formatted number "100" can be parsed as number at Druid 
server side. 
   
   ### Key changes
   
   #12833 adds a method `getContextHumanReadableBytes` to get context value 
from any acceptable format safely. And this PR adds a group of methods to do so 
and changes all existing code reference to the new APIs.
   
   Newly added methods are:
   
   ```java
   getContextAsInt
   getContextAsLong
   getContextAsFloat
   getContextAsString
   getContextAsEnum
   getContextAsBoolean
   ```
   
   Original unsafe method `getContextValue` is still kept to allow us get 
objects which are stored by Druid server side temporarily.
   Some javadoc is added to tell callers know which methods should be used 
instead.
   
   
   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/dev/license.md)
   - [ ] 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.
   


-- 
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]

Reply via email to