ankitsultana opened a new issue, #15442:
URL: https://github.com/apache/pinot/issues/15442

   This query generates an incorrect plan:
   
   ```
   SET useMultistageEngine=true;
   
   EXPLAIN PLAN FOR SELECT userUUID
   FROM userAttributes
   WHERE (deviceOS IN ('foo')
     OR userUUID IN (
       SELECT userUUID
       FROM userGroups
       WHERE groupUUID = 'group-1'
     ))
   ```
   
   The plan contains two joins as you would expect, but the first join is a 
key-less inner join where the right input is an aggregate with an empty 
grouping set (i.e. a single value is returned from the right input which is 
number of rows matching `groupUUID = 'group-1'`).
   
   ```
   Execution Plan
   LogicalProject(userUUID=[$1])
     LogicalFilter(condition=[OR(=($0, _UTF-8'foo'), CAST(OR(AND(IS NOT 
NULL($6), <>($2, 0)), AND(<($3, $2), null, <>($2, 0), IS NULL($6)))):BOOLEAN 
NOT NULL)])
       LogicalJoin(condition=[=($4, $5)], joinType=[left])
         PinotLogicalExchange(distribution=[hash[4]])
           LogicalProject(deviceOS=[$0], userUUID=[$1], $f0=[$2], $f1=[$3], 
userUUID0=[$1])
             LogicalJoin(condition=[true], joinType=[inner])
               PinotLogicalExchange(distribution=[random])
                 LogicalProject(deviceOS=[$4], userUUID=[$6])
                   PinotLogicalTableScan(table=[[default, userattributes]])
               PinotLogicalExchange(distribution=[broadcast])
                 LogicalProject($f0=[$0], $f00=[$0])
                   PinotLogicalAggregate(group=[{}], agg#0=[COUNT($0)], 
aggType=[FINAL])
                     PinotLogicalExchange(distribution=[hash])
                       PinotLogicalAggregate(group=[{}], agg#0=[COUNT()], 
aggType=[LEAF])
                         LogicalFilter(condition=[=($3, _UTF-8'group-1')])
                           PinotLogicalTableScan(table=[[default, usergroups]])
         PinotLogicalExchange(distribution=[hash[0]])
           PinotLogicalAggregate(group=[{0}], agg#0=[MIN($1)], aggType=[FINAL])
             PinotLogicalExchange(distribution=[hash[0]])
               PinotLogicalAggregate(group=[{0}], agg#0=[MIN($1)], 
aggType=[LEAF])
                 LogicalProject(userUUID=[$4], $f1=[true])
                   LogicalFilter(condition=[=($3, _UTF-8'group-1')])
                     PinotLogicalTableScan(table=[[default, usergroups]])
   ```


-- 
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: commits-unsubscr...@pinot.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to