You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/06/10 21:41:36 UTC
[GitHub] [druid] paul-rogers opened a new pull request, #12634: Remove null and empty fields from native queries
paul-rogers opened a new pull request, #12634:
URL: https://github.com/apache/druid/pull/12634
This is a subset of the changes for the [planner test framework](https://github.com/apache/druid/pull/12545), split out to make reviews easier.
Druid native queries are often serialized to JSON. In the planner framework, we save the JSON as an "expected plan." To make the resulting files a bit smaller, this PR removes from the JSON those fields with default values: values that Jackson would infer even if the fields are not present. For example, rather than spelling out `"foo": null`, we can simply omit `"foo"` and get the same results. The same is true for `"foo": {}` and `"foo": []` since most constructors will create an empty collection if passed a null.
The clean-up is done using the `@JsonInclude` annotation, sometimes with a custom filter class. Scan Query has a batch size which defaults to `4096 * 5` if the provided value is 0. Given this, added a filter which omits the value if it is the default, which avoids cluttering the deserialized JSON with magic numbers.
Some unit tests check for an exact serialization of the JSON, including the now-removed `null` fields. All such tests were updated with the revised format.
This change is purely cosmetic: the deserialized query objects do not change meaning. Tested via unit tests, including the new planner test framework.
<hr>
This PR has:
- [X] been self-reviewed.
- [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.
- [ ] 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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] lgtm-com[bot] commented on pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on PR #12634:
URL: https://github.com/apache/druid/pull/12634#issuecomment-1152801113
This pull request **introduces 3 alerts** when merging 1c70cf152c2cbad8814122c05dc1ed9f1c9cb4fe into 1ace7336cd292babea75a6bd589e836f68f30007 - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-4bc5f85507e9916a7e5979d519815fb67e5d1df6)
**new alerts:**
* 3 for Inconsistent equals and hashCode
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] lgtm-com[bot] commented on pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on PR #12634:
URL: https://github.com/apache/druid/pull/12634#issuecomment-1154524001
This pull request **introduces 3 alerts** when merging 922087b0c47193fc044638b6a544f16055532258 into 1ace7336cd292babea75a6bd589e836f68f30007 - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-b91a4138ef1f4cc68a5f22872fa195f00eb1bac1)
**new alerts:**
* 3 for Inconsistent equals and hashCode
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] gianm commented on a diff in pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
gianm commented on code in PR #12634:
URL: https://github.com/apache/druid/pull/12634#discussion_r896244700
##########
processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java:
##########
@@ -313,9 +319,9 @@ public LimitSpec getLimitSpec()
return limitSpec;
}
- @JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty("subtotalsSpec")
@Nullable
+ @JsonProperty("subtotalsSpec")
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
Review Comment:
IIRC empty `subtotalsSpec` is treated differently from null `subtotalsSpec`. If that's accurate then this should be `NON_NULL`.
##########
processing/src/main/java/org/apache/druid/query/filter/SelectorDimFilter.java:
##########
@@ -118,21 +119,23 @@ public String getDimension()
@Nullable
@JsonProperty
+ @JsonInclude(JsonInclude.Include.NON_NULL)
Review Comment:
IMO, it would be better to omit the `@JsonInclude` here. `value` is a required parameter for the selector filter, and `value: null` represents an "is null" filter. It's weird for the canonical JSON form of an "is null" filter to not have any `value` at all.
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] lgtm-com[bot] commented on pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on PR #12634:
URL: https://github.com/apache/druid/pull/12634#issuecomment-1155789865
This pull request **introduces 3 alerts** when merging ec675309891dd0f2e2d945472817e7427ab42d21 into 1f6e888472d3102f574a088286f92cb8feff4c86 - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-cb1344a551c7e33151bd1775b0d349185d39cc8f)
**new alerts:**
* 3 for Inconsistent equals and hashCode
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] lgtm-com[bot] commented on pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on PR #12634:
URL: https://github.com/apache/druid/pull/12634#issuecomment-1153074152
This pull request **introduces 3 alerts** when merging e9a623cb554058442dd35010c078d84356074bc4 into 1ace7336cd292babea75a6bd589e836f68f30007 - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-6bacd08ec58d9547c6872a76eb78f2b4f1d140d7)
**new alerts:**
* 3 for Inconsistent equals and hashCode
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] lgtm-com[bot] commented on pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on PR #12634:
URL: https://github.com/apache/druid/pull/12634#issuecomment-1154616252
This pull request **introduces 3 alerts** when merging a93bf0d7a62eed7bc4d48784d4608f626b621afa into 27e8b43673af6e6f6cabbea66582569577d4f613 - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-d802c0bb59c416ef182041059c26eb473bc0d982)
**new alerts:**
* 3 for Inconsistent equals and hashCode
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] lgtm-com[bot] commented on pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on PR #12634:
URL: https://github.com/apache/druid/pull/12634#issuecomment-1156909079
This pull request **introduces 3 alerts** when merging 2969d46e381688412bc4015d7a69edbc2f9b3771 into 45e31115495838b3327e0fff1d21bee0adf31132 - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-8cc8efe259d4e7de0e2206613d0638cedab785a9)
**new alerts:**
* 3 for Inconsistent equals and hashCode
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] gianm merged pull request #12634: Remove null and empty fields from native queries
Posted by GitBox <gi...@apache.org>.
gianm merged PR #12634:
URL: https://github.com/apache/druid/pull/12634
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org