LakshSingla commented on code in PR #15020:
URL: https://github.com/apache/druid/pull/15020#discussion_r1335177622


##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java:
##########
@@ -788,6 +790,28 @@ static Pair<DataSource, Filtration> getFiltration(
   {
     if (!canUseIntervalFiltering(dataSource)) {
       return Pair.of(dataSource, toFiltration(filter, 
virtualColumnRegistry.getFullRowSignature(), false));
+    } else if (dataSource instanceof UnnestDataSource) {
+      // UnnestDataSource can have another unnest data source
+      // join datasource, filtered data source, etc as base
+      Pair<DataSource, Filtration> pair = getFiltration(
+          ((UnnestDataSource) dataSource).getBase(),
+          filter,
+          virtualColumnRegistry,
+          joinableFactoryWrapper
+      );
+      return Pair.of(dataSource, pair.rhs);
+    } else if (dataSource instanceof FilteredDataSource) {
+      final FilteredDataSource filteredDataSource = (FilteredDataSource) 
dataSource;
+      final boolean useIntervalFiltering = 
canUseIntervalFiltering(filteredDataSource);
+      final Filtration baseFiltration = toFiltration(
+          filteredDataSource.getFilter(),
+          virtualColumnRegistry.getFullRowSignature(),
+          useIntervalFiltering
+      );
+      // Adds the intervals from the filter of filtered data source to query 
filtration
+      final Filtration queryFiltration = Filtration.create(filter, 
baseFiltration.getIntervals())
+                                                   
.optimize(virtualColumnRegistry.getFullRowSignature());

Review Comment:
   `toFiltration` in the above call is already optimizing. Why do we require 
this again?



##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java:
##########
@@ -788,6 +790,28 @@ static Pair<DataSource, Filtration> getFiltration(
   {
     if (!canUseIntervalFiltering(dataSource)) {
       return Pair.of(dataSource, toFiltration(filter, 
virtualColumnRegistry.getFullRowSignature(), false));
+    } else if (dataSource instanceof UnnestDataSource) {

Review Comment:
   nit: It won't make a difference with the logic as is, but let's put this 
branch at the top since it is the most specific of the branches.



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