clintropolis commented on code in PR #18042:
URL: https://github.com/apache/druid/pull/18042#discussion_r2114638051


##########
processing/src/main/java/org/apache/druid/query/planning/PreJoinableClause.java:
##########
@@ -64,6 +68,29 @@ public DataSource getDataSource()
     return dataSource;
   }
 
+  /**
+   * If the data source is a {@link RestrictedDataSource} with a {@link 
NoRestrictionPolicy}, unwraps it to a table and return.
+   * <p>
+   * This is a temporary workaround to allow the planner to work with {@link 
RestrictedDataSource} as the right-side join.
+   */
+  public DataSource maybeUnwrapRestrictedDataSource()
+  {
+    if (dataSource instanceof RestrictedDataSource) {
+      RestrictedDataSource restricted = (RestrictedDataSource) dataSource;
+      if (restricted.getPolicy() instanceof NoRestrictionPolicy) {
+        return restricted.getBase();
+      } else {
+        throw new QueryUnsupportedException(StringUtils.format(

Review Comment:
   eh, unsupported seems ok to me, since the error would happen if the user was 
writing a query that used a table on rhs of join that had policy restrictions 
defined, where as i think of defensive as a developer exception



##########
processing/src/main/java/org/apache/druid/query/RestrictedDataSource.java:
##########
@@ -138,13 +138,8 @@ public DataSource withPolicies(Map<String, 
Optional<Policy>> policyMap, PolicyEn
 
     Optional<Policy> newPolicy = policyMap.getOrDefault(base.getName(), 
Optional.empty());
     if (newPolicy.isEmpty()) {
-      throw new ISE(
-          "No restriction found on table [%s], but had policy [%s] before.",
-          base.getName(),
-          policy
-      );
-    }
-    if (newPolicy.get() instanceof NoRestrictionPolicy) {
+      // allow empty policy, which means no restriction.

Review Comment:
   since empty means no restriction, should this be consolidated with the next 
else if? 
   ```if (newPolicy.isEmpty() || newPolicy.get() instance NoRestrictionPolicy) 
{ ...```



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