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


##########
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:
   This message is off for the target persona. `SegmentMetadataQuery` is a Java 
class, which we shouldn't use in messages targeted at the User persona. The 
User persona doesn't know about Java classes and isn't expected to be reading 
the code. They should see the JSON type name, which in this case is 
`segmentMetadata`. So something like "You do not have permission to run a 
segmentMetadata query on table[%s]."



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