-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fix join filter rewrites with nested queries #9978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3c84e62
Fix join filter rewrites with nested queries
jon-wei d3b3055
Add javadocs, fix inspections
jon-wei da4af6b
Remove unused imports and method
jon-wei f96752f
Fix overrides
jon-wei 1726531
Address PR comments
jon-wei d74ff79
Fixes
jon-wei 8024443
Restore @Override
jon-wei d79b301
Fix inspections and tests
jon-wei b6bd57d
Memoize, change test name
jon-wei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,12 +20,14 @@ | |
| package org.apache.druid.query.filter; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.google.common.base.Joiner; | ||
| import com.google.common.base.Preconditions; | ||
| import com.google.common.collect.RangeSet; | ||
| import com.google.common.collect.TreeRangeSet; | ||
| import org.apache.druid.java.util.common.StringUtils; | ||
| import org.apache.druid.query.cache.CacheKeyBuilder; | ||
| import org.apache.druid.segment.filter.AndFilter; | ||
| import org.apache.druid.segment.filter.Filters; | ||
|
|
||
|
|
@@ -43,6 +45,9 @@ public class AndDimFilter implements DimFilter | |
|
|
||
| private final List<DimFilter> fields; | ||
|
|
||
| @JsonIgnore | ||
| private Integer fieldsHashCode; | ||
|
|
||
| @JsonCreator | ||
| public AndDimFilter( | ||
| @JsonProperty("fields") List<DimFilter> fields | ||
|
|
@@ -67,7 +72,7 @@ public List<DimFilter> getFields() | |
| @Override | ||
| public byte[] getCacheKey() | ||
| { | ||
| return DimFilterUtils.computeCacheKey(DimFilterUtils.AND_CACHE_ID, fields); | ||
| return new CacheKeyBuilder(DimFilterUtils.AND_CACHE_ID).appendInt(hashCode()).build(); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -142,7 +147,10 @@ public boolean equals(Object o) | |
| @Override | ||
| public int hashCode() | ||
| { | ||
| return fields != null ? fields.hashCode() : 0; | ||
| if (fieldsHashCode == null) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this need to be threadsafe? Might want to put behind a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed this and elsewhere to use Supplier.memoize |
||
| fieldsHashCode = fields != null ? fields.hashCode() : 0; | ||
| } | ||
| return fieldsHashCode; | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to detect this and use the different modes automatically since it sounds like the old mode is perhaps better if there are no subqueries involved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think that could be worth looking into later on