Skip to content

[multistage] multiple nested SEMI-join create wrong plan #11881

@walterddr

Description

@walterddr

running this in the colocated quickstart

explain plan for
WITH tmp2 AS (
  SELECT * FROM userGroups
  WHERE groupUUID NOT IN ('group-3', 'group-4')
),
tmp3 AS (
  SELECT *
  FROM userAttributes
  WHERE userUUID IN (SELECT userUUID FROM tmp2)
    AND totalTrips < 100
)
SELECT * FROM tmp3 WHERE userUUID IN (SELECT userUUID from tmp2)

produces

Execution Plan
LogicalJoin(condition=[=($3, $5)], joinType=[semi])
  PinotLogicalExchange(distribution=[hash[3]])      <-- THIS should be the right exchange
    PinotLogicalExchange(distribution=[hash[3]])      <-- THIS exchange is redundant
      LogicalJoin(condition=[=($3, $5)], joinType=[semi])
        LogicalProject(daysSinceFirstTrip=[$3], deviceOS=[$4], totalTrips=[$5], userUUID=[$6])
          LogicalFilter(condition=[<($5, 100)])
            LogicalTableScan(table=[[userAttributes]])
        PinotLogicalExchange(distribution=[broadcast], relExchangeType=[PIPELINE_BREAKER])
          LogicalProject(groupUUID=[$3], userUUID=[$4])
            LogicalFilter(condition=[AND(<>($3, 'group-3'), <>($3, 'group-4'))])
              LogicalTableScan(table=[[userGroups]])
  PinotLogicalExchange(distribution=[hash[1]])
    LogicalProject(groupUUID=[$3], userUUID=[$4])
      LogicalFilter(condition=[AND(<>($3, 'group-3'), <>($3, 'group-4'))])
        LogicalTableScan(table=[[userGroups]])

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmulti-stageRelated to the multi-stage query engine

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions