-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[MSQ] Confirm that the allocated segment's granularity matches the requested granularity #14475
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,13 +19,16 @@ | |
|
|
||
| package org.apache.druid.msq.util; | ||
|
|
||
| import org.apache.druid.java.util.common.Intervals; | ||
| import org.apache.druid.java.util.common.granularity.AllGranularity; | ||
| import org.apache.druid.java.util.common.granularity.Granularity; | ||
| import org.joda.time.Interval; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Things that would make sense in {@link org.apache.druid.java.util.common.Intervals} if this were not an extension. | ||
| * Things that would make sense in {@link Intervals} if this were not an extension. | ||
| */ | ||
| public class IntervalUtils | ||
| { | ||
|
|
@@ -61,4 +64,21 @@ public static List<Interval> difference(final List<Interval> list1, final List<I | |
|
|
||
| return retVal; | ||
| } | ||
|
|
||
| /** | ||
| * This method checks if the provided interval is aligned by the granularity or is an instance of {@link Intervals#ETERNITY} | ||
| * This is used to check if the granularity allocation made by the overlord is the same as the one requested in the | ||
| * SQL query | ||
| */ | ||
| public static boolean isAligned( | ||
| final Interval interval, | ||
| final Granularity granularity | ||
| ) | ||
| { | ||
| // AllGranularity needs special handling since AllGranularity#bucketStart always returns false | ||
|
Contributor
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 suppose we could fix
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 was not confident if that would break any pre-existing logic. Also, Javadoc states: Therefore I found suitable to extract the logic as a helper method |
||
| if (granularity instanceof AllGranularity) { | ||
| return Intervals.isEternity(interval); | ||
| } | ||
| return granularity.isAligned(interval); | ||
| } | ||
| } | ||
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.
Maybe add this method to
Intervalsclass instead, as it could have uses outside the MSQ extension too.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.
Left this method in the interval utils since the top-level Javadoc for IntervalUtils mentions that the methods are specific to MSQ for now, and would make more sense to move to Intervals if MSQ wasn't an extension