abhishekrb19 commented on code in PR #16324:
URL: https://github.com/apache/druid/pull/16324#discussion_r1576693702


##########
server/src/main/java/org/apache/druid/segment/indexing/granularity/UniformGranularitySpec.java:
##########
@@ -45,6 +47,15 @@ public UniformGranularitySpec(
     super(inputIntervals, rollup);
     this.queryGranularity = queryGranularity == null ? 
DEFAULT_QUERY_GRANULARITY : queryGranularity;
     this.segmentGranularity = segmentGranularity == null ? 
DEFAULT_SEGMENT_GRANULARITY : segmentGranularity;
+    if (Granularity.IS_FINER_THAN.compare(this.segmentGranularity, 
this.queryGranularity) < 0) {
+      throw DruidException.forPersona(DruidException.Persona.USER)
+                          .ofCategory(DruidException.Category.UNSUPPORTED)
+                          .build(
+                              "SegmentGranularity[%s] must not be finer than 
QueryGranularity[%s].",
+                              this.segmentGranularity,
+                              this.queryGranularity
+                          );

Review Comment:
   `UNSUPPORTED` is mapped to a 5xx error code. We can return an invalid input 
in this case:
   ```suggestion
         throw InvalidInput.exception(
            "segmentGranularity[%s] cannot be finer than 
queryGranularity[%s].", 
             this.segmentGranularity, this.queryGranularity
         );
   ```
   also, it'd be better to capitalize the properties in the error message as a 
user would specify in the spec.



##########
server/src/test/java/org/apache/druid/segment/indexing/granularity/UniformGranularityTest.java:
##########
@@ -358,6 +359,18 @@ public void 
testUniformGranularitySpecWithLargeNumberOfIntervalsDoesNotBlowUp()
     Assert.assertEquals(3600 * 24 * 365 * 10 + 3 * 24 * 3600, count);
   }
 
+  @Test(expected = DruidException.class)

Review Comment:
   For junit 5.x.x compatibility, use `Assert.assertThrows()` with the 
`DruidExceptionMatch`



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