Function hash_join_swap_subrule

Source
pub fn hash_join_swap_subrule(
    input: Arc<dyn ExecutionPlan>,
    _config_options: &ConfigOptions,
) -> Result<Arc<dyn ExecutionPlan>>
Expand description

This subrule will swap build/probe sides of a hash join depending on whether one of its inputs may produce an infinite stream of records. The rule ensures that the left (build) side of the hash join always operates on an input stream that will produce a finite set of records. If the left side can not be chosen to be “finite”, the join sides stay the same as the original query.

For example, this rule makes the following transformation:



          +--------------+              +--------------+
          |              |  unbounded   |              |
   Left   | Infinite     |    true      | Hash         |\true
          | Data source  |--------------| Repartition  | \   +--------------+       +--------------+
          |              |              |              |  \  |              |       |              |
          +--------------+              +--------------+   - |  Hash Join   |-------| Projection   |
                                                           - |              |       |              |
          +--------------+              +--------------+  /  +--------------+       +--------------+
          |              |  unbounded   |              | /
   Right  | Finite       |    false     | Hash         |/false
          | Data Source  |--------------| Repartition  |
          |              |              |              |
          +--------------+              +--------------+



          +--------------+              +--------------+
          |              |  unbounded   |              |
   Left   | Finite       |    false     | Hash         |\false
          | Data source  |--------------| Repartition  | \   +--------------+       +--------------+
          |              |              |              |  \  |              | true  |              | true
          +--------------+              +--------------+   - |  Hash Join   |-------| Projection   |-----
                                                           - |              |       |              |
          +--------------+              +--------------+  /  +--------------+       +--------------+
          |              |  unbounded   |              | /
   Right  | Infinite     |    true      | Hash         |/true
          | Data Source  |--------------| Repartition  |
          |              |              |              |
          +--------------+              +--------------+