Adding dropResults parameter in queryOptions to drop the resultTable field from the response#10419
Merged
mayankshriv merged 3 commits intoapache:masterfrom Mar 16, 2023
Merged
Conversation
…field from the response.
| if (request.has(Broker.Request.QUERY_OPTIONS)) { | ||
| String queryOptions = request.get(Broker.Request.QUERY_OPTIONS).asText(); | ||
| Map<String, String> optionsFromString = RequestUtils.getOptionsFromString(queryOptions); | ||
| if (optionsFromString.getOrDefault(Broker.Request.QueryOptionKey.DROP_RESULTS, "false") |
Contributor
There was a problem hiding this comment.
You may put this logic into QueryOptionsUtils
Contributor
There was a problem hiding this comment.
It is equivalent to Boolean.parseBoolean(queryOptions.get(QueryOptionKey.DROP_RESULTS))
mayankshriv
approved these changes
Mar 15, 2023
Codecov Report
@@ Coverage Diff @@
## master #10419 +/- ##
=============================================
- Coverage 70.32% 24.43% -45.90%
+ Complexity 6105 49 -6056
=============================================
Files 2055 2028 -27
Lines 111389 110638 -751
Branches 16939 16850 -89
=============================================
- Hits 78337 27034 -51303
- Misses 27566 80780 +53214
+ Partials 5486 2824 -2662
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1538 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Jackie-Jiang
approved these changes
Mar 16, 2023
Comment on lines
+197
to
+209
| public static boolean isDropResultsEnabled(final JsonNode request) { | ||
| boolean dropResults = false; | ||
|
|
||
| if (request.has(CommonConstants.Broker.Request.QUERY_OPTIONS)) { | ||
| String queryOptions = request.get(CommonConstants.Broker.Request.QUERY_OPTIONS).asText(); | ||
| Map<String, String> optionsFromString = RequestUtils.getOptionsFromString(queryOptions); | ||
| if (Boolean.parseBoolean(optionsFromString.get(CommonConstants.Broker.Request.QueryOptionKey.DROP_RESULTS))) { | ||
| dropResults = true; | ||
| } | ||
| } | ||
|
|
||
| return dropResults; | ||
| } |
Contributor
There was a problem hiding this comment.
We want to take the Map here instead of the JsonNode. The logic of extracting the map should be on the caller side. Also suggest rename it
Suggested change
| public static boolean isDropResultsEnabled(final JsonNode request) { | |
| boolean dropResults = false; | |
| if (request.has(CommonConstants.Broker.Request.QUERY_OPTIONS)) { | |
| String queryOptions = request.get(CommonConstants.Broker.Request.QUERY_OPTIONS).asText(); | |
| Map<String, String> optionsFromString = RequestUtils.getOptionsFromString(queryOptions); | |
| if (Boolean.parseBoolean(optionsFromString.get(CommonConstants.Broker.Request.QueryOptionKey.DROP_RESULTS))) { | |
| dropResults = true; | |
| } | |
| } | |
| return dropResults; | |
| } | |
| public static boolean shouldDropResults(Map<String, String> queryOptions) { | |
| return Boolean.parseBoolean(queryOptions.get(CommonConstants.Broker.Request.QueryOptionKey.DROP_RESULTS)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a parameter to queryOptions to drop the resultTable from the response. This mode can be used to troubleshoot a customer's query (which may have sensitive data in the result) using metadata only.
Manual testing report:
Added integration tests as well.