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


##########
processing/src/main/java/org/apache/druid/query/metadata/metadata/SegmentMetadataQuery.java:
##########
@@ -107,7 +110,17 @@ public SegmentMetadataQuery(
     this.toInclude = toInclude == null ? new AllColumnIncluderator() : 
toInclude;
     this.merge = merge == null ? false : merge;
     this.analysisTypes = analysisTypes;
-    if (!(dataSource instanceof TableDataSource || dataSource instanceof 
UnionDataSource)) {
+    if (dataSource instanceof RestrictedDataSource) {
+      Policy policy = ((RestrictedDataSource) dataSource).getPolicy();
+      // Only no-restriction policy is allowed for segment metadata queries.
+      if (!(policy instanceof NoRestrictionPolicy)) {
+        throw InvalidInput.exception(
+            "Only NoRestrictionPolicy is allowed for SegmentMetadataQuery on 
dataSource[%s], found policy[%s].",
+            ((RestrictedDataSource) dataSource).getBase(),
+            policy
+        );
+      }
+    } else if (!(dataSource instanceof TableDataSource || dataSource 
instanceof UnionDataSource)) {

Review Comment:
   I tried to add a test case in `SegmentMetadataQuerySegmentWalkerTest` for a 
Union of a single table, it failed with 
   
   ```
   org.apache.druid.error.DruidException: Base 
dataSource[UnionDataSource{dataSources=[testDatasource]}] is not a table!
   
        at 
org.apache.druid.query.planning.DataSourceAnalysis.getBaseTableDataSource(DataSourceAnalysis.java:133)
        at org.apache.druid.query.Queries.withSpecificSegments(Queries.java:170)
        at 
org.apache.druid.segment.metadata.SegmentMetadataQuerySegmentWalker.getServerResults(SegmentMetadataQuerySegmentWalker.java:193)
        at 
org.apache.druid.segment.metadata.SegmentMetadataQuerySegmentWalker.lambda$run$0(SegmentMetadataQuerySegmentWalker.java:170)
        at java.base/java.util.TreeMap.forEach(TreeMap.java:1282)
        at 
org.apache.druid.segment.metadata.SegmentMetadataQuerySegmentWalker.run(SegmentMetadataQuerySegmentWalker.java:159)
        at 
org.apache.druid.segment.metadata.SegmentMetadataQuerySegmentWalker$1.run(SegmentMetadataQuerySegmentWalker.java:104)
        at 
org.apache.druid.server.SetAndVerifyContextQueryRunner.run(SetAndVerifyContextQueryRunner.java:52)
        at 
org.apache.druid.query.CPUTimeMetricQueryRunner.run(CPUTimeMetricQueryRunner.java:64)
        at 
org.apache.druid.query.FluentQueryRunner.run(FluentQueryRunner.java:52)
   ```
   
   i wonder maybe we no longer support union for segment query. 



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