src/backend/executor/abstract_join_executor.cpp
/*
 * build right join output by adding null rows for every row from left tile
 * which doesn't have a match
 */
build right join output by adding null rows for every row from left tile
which doesn't have a match
build right join output by adding null rows for every row from left tile which doesn ' t have a match
bool AbstractJoinExecutor::BuildRightJoinOutput() {
  while (right_matching_idx < no_matching_right_row_sets_.size()) {
    if (no_matching_right_row_sets_[right_matching_idx].empty()) {
      right_matching_idx++;
      continue;
    }
    std::unique_ptr<LogicalTile> output_tile(nullptr);
    auto right_tile = right_result_tiles_[right_matching_idx].get();
    LogicalTile::PositionListsBuilder pos_lists_builder;
    if (left_result_tiles_.size() == 0) {
      output_tile = BuildOutputLogicalTile(nullptr, right_tile, proj_schema_);
      pos_lists_builder = LogicalTile::PositionListsBuilder(
          nullptr, &(right_tile->GetPositionLists()));
    } else {
      assert(left_result_tiles_.size() > 0);
      auto left_tile = left_result_tiles_.front().get();
      output_tile = BuildOutputLogicalTile(left_tile, right_tile);
      pos_lists_builder =
          LogicalTile::PositionListsBuilder(left_tile, right_tile);
    }
    for (auto right_row_itr : no_matching_right_row_sets_[right_matching_idx]) {
      pos_lists_builder.AddLeftNullRow(right_row_itr);
    }
    assert(pos_lists_builder.Size() > 0);
    output_tile->SetPositionListsAndVisibility(pos_lists_builder.Release());
    SetOutput(output_tile.release());
    right_matching_idx++;
    return true;
  }
  return false;
}
bool AbstractJoinExecutor :: BuildRightJoinOutput ( ) { while ( right_matching_idx < no_matching_right_row_sets_ . size ( ) ) { if ( no_matching_right_row_sets_ [ right_matching_idx ] . empty ( ) ) { right_matching_idx ++ ; continue ; } std :: unique_ptr < LogicalTile > output_tile ( nullptr ) ; auto right_tile = right_result_tiles_ [ right_matching_idx ] . get ( ) ; LogicalTile :: PositionListsBuilder pos_lists_builder ; if ( left_result_tiles_ . size ( ) == 0 ) { output_tile = BuildOutputLogicalTile ( nullptr , right_tile , proj_schema_ ) ; pos_lists_builder = LogicalTile :: PositionListsBuilder ( nullptr , & ( right_tile -> GetPositionLists ( ) ) ) ; } else { assert ( left_result_tiles_ . size ( ) > 0 ) ; auto left_tile = left_result_tiles_ . front ( ) . get ( ) ; output_tile = BuildOutputLogicalTile ( left_tile , right_tile ) ; pos_lists_builder = LogicalTile :: PositionListsBuilder ( left_tile , right_tile ) ; } for ( auto right_row_itr : no_matching_right_row_sets_ [ right_matching_idx ] ) { pos_lists_builder . AddLeftNullRow ( right_row_itr ) ; } assert ( pos_lists_builder . Size ( ) > 0 ) ; output_tile -> SetPositionListsAndVisibility ( pos_lists_builder . Release ( ) ) ; SetOutput ( output_tile . release ( ) ) ; right_matching_idx ++ ; return true ; } return false ; }
build right join output by adding null rows for every row from left tile
 which doesn't have a match
build right join output by adding null rows for every row from left tile which doesn ' t have a match
// no tile information for left tile. construct a output tile from right // tile only // construct the output tile from both children tiles // add rows with null values on the left