This is an automated email from the ASF dual-hosted git repository.

FrankChen021 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new cfc85ea16f0 minor: Require withPolicies for LeafDataSources with 
tables. (#20705)
cfc85ea16f0 is described below

commit cfc85ea16f0958355e5ffecc78adf5941f70aa33
Author: Gian Merlino <[email protected]>
AuthorDate: Fri Oct 23 06:06:28 2026 -0700

    minor: Require withPolicies for LeafDataSources with tables. (#20705)
    
    LeafDataSource implementations that have table names must override
    withPolicies so they can apply the relevant policies.
---
 .../main/java/org/apache/druid/query/LeafDataSource.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git 
a/processing/src/main/java/org/apache/druid/query/LeafDataSource.java 
b/processing/src/main/java/org/apache/druid/query/LeafDataSource.java
index 20541056fef..24690d12c13 100644
--- a/processing/src/main/java/org/apache/druid/query/LeafDataSource.java
+++ b/processing/src/main/java/org/apache/druid/query/LeafDataSource.java
@@ -19,16 +19,21 @@
 
 package org.apache.druid.query;
 
+import org.apache.druid.error.DruidException;
 import org.apache.druid.java.util.common.IAE;
 import org.apache.druid.query.filter.DimFilter;
 import org.apache.druid.query.filter.FilterSegmentPruner;
 import org.apache.druid.query.filter.SegmentPruner;
+import org.apache.druid.query.policy.Policy;
+import org.apache.druid.query.policy.PolicyEnforcer;
 import org.apache.druid.segment.SegmentMapFunction;
 import org.apache.druid.segment.VirtualColumns;
 
 import javax.annotation.Nullable;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
 /**
@@ -65,6 +70,17 @@ public abstract class LeafDataSource implements DataSource
     return filter == null ? null : new FilterSegmentPruner(filter, null, 
virtualColumns);
   }
 
+  @Override
+  public DataSource withPolicies(Map<String, Optional<Policy>> policyMap, 
PolicyEnforcer policyEnforcer)
+  {
+    if (getTableNames().isEmpty()) {
+      // No need to call the default method, because a leaf with no tables has 
nothing to apply policies to.
+      return this;
+    } else {
+      throw DruidException.defensive("Class[%s] can have tables, it must 
override withPolicies", getClass());
+    }
+  }
+
   @Override
   public Set<String> getReservedColumns()
   {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to