somu-imply commented on PR #13799:
URL: https://github.com/apache/druid/pull/13799#issuecomment-1449047935

   >It seems like you could potentially decompose the filter to partially push 
down anything that is is not filtering on the output column name into the base 
cursor so that the query can still use indexes and such, since otherwise the 
implication here is that if any filter is on the unnest column then it means we 
aren't going to use any indexes since we aren't pushing filter down to the base 
cursor.
   
   Calcite is smart enough to push the filter on an existing dimension to the 
underlying datasource. For example a query like
   ```with t as (select * from druid.numfoo,UNNEST(MV_TO_ARRAY(dim3)) as 
foo(d3))
   select d3 from t where d3 >1 AND dim2 IN ('a','b')```
   
   Calcite plans it as
   ```
   157:LogicalProject(d3=[$17])
     155:LogicalCorrelate(subset=[rel#156:Subset#7.NONE.[]], 
correlation=[$cor0], joinType=[inner], requiredColumns=[{3}])
       144:LogicalFilter(subset=[rel#145:Subset#1.NONE.[]], condition=[OR(=($2, 
'a'), =($2, 'b'))])
         9:LogicalTableScan(subset=[rel#143:Subset#0.NONE.[]], table=[[druid, 
numfoo]])
       151:LogicalFilter(subset=[rel#152:Subset#5.NONE.[]], 
condition=[>(CAST($0):INTEGER, 1)])
         149:Uncollect(subset=[rel#150:Subset#4.NONE.[]])
           147:LogicalProject(subset=[rel#148:Subset#3.NONE.[]], 
EXPR$0=[MV_TO_ARRAY($cor0.dim3)])
             10:LogicalValues(subset=[rel#146:Subset#2.NONE.[0]], tuples=[[{ 0 
}]])
   ```


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