LakshSingla commented on code in PR #14475:
URL: https://github.com/apache/druid/pull/14475#discussion_r1241505628


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/IntervalUtils.java:
##########
@@ -61,4 +64,20 @@ 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 
provided and if it occupies exactly
+   * one "unit" of the granularity
+   * Note: ALL granularity isn't aligned to any interval, however this method 
is defines that ALL granularity matches
+   * an interval with boundary ({@code DateTimes.MIN}, {@code DateTimes.MAX})
+   */
+  public static boolean doesIntervalMatchesGranularity(final Interval 
interval, final Granularity granularity)
+  {
+    // AllGranularity needs special handling since AllGranularity#bucketStart 
always returns false
+    if (granularity instanceof AllGranularity) {
+      return (interval.getStartMillis() == DateTimes.MIN.getMillis())
+             && (interval.getEndMillis() == DateTimes.MAX.getMillis());
+    }
+    return granularity.isAligned(interval) && 
granularity.bucketEnd(interval.getStart()).equals(interval.getEnd());

Review Comment:
   Thanks for the clarification, I understand why isAligned checks that the 
interval fits exactly into the granularity. Refactored  



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