cecemei commented on code in PR #17864:
URL: https://github.com/apache/druid/pull/17864#discussion_r2036256140


##########
processing/src/main/java/org/apache/druid/query/metadata/metadata/SegmentMetadataQuery.java:
##########
@@ -245,6 +248,34 @@ public List<Interval> getIntervals()
     return this.getQuerySegmentSpec().getIntervals();
   }
 
+  private static void validateDataSource(DataSource dataSource)
+  {
+    if (dataSource instanceof TableDataSource) {
+      // do nothing
+    } else if (dataSource instanceof RestrictedDataSource) {
+      validateWithNoRestrictionPolicy((RestrictedDataSource) dataSource);
+    } else if (dataSource instanceof UnionDataSource) {
+      for (DataSource child : dataSource.getChildren()) {
+        validateDataSource(child);
+      }
+    } else {
+      throw InvalidInput.exception("Invalid dataSource type [%s]. "
+                                   + "SegmentMetadataQuery only supports table 
or union datasources.", dataSource);
+    }
+  }
+
+  private static void validateWithNoRestrictionPolicy(RestrictedDataSource 
restricted)
+  {
+    if (!(restricted.getPolicy() instanceof NoRestrictionPolicy)) {
+      throw DruidException.forPersona(DruidException.Persona.USER)
+                          .ofCategory(DruidException.Category.FORBIDDEN)
+                          .build(
+                              "You do not have permission to run a 
SegmentMetadataQuery on table[%s].",

Review Comment:
   updated, IT is a bit flaky but tests are looking good!



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