update_coalesce_ctx_children

Function update_coalesce_ctx_children 

Source
fn update_coalesce_ctx_children(
    coalesce_context: &mut PlanWithCorrespondingCoalescePartitions,
)
Expand description

Discovers the linked Coalesce->Sort cascades.

This linkage is used in remove_bottleneck_in_subplan to selectively remove the linked coalesces in the subplan. Then afterwards, an SPM is added at the root of the subplan (just after the sort) in order to parallelize sorts. Refer to the parallelize_sorts for more details on sort parallelization.

Example of linked Coalesce->Sort:

SortExec ctx.data=false, to halt remove_bottleneck_in_subplan)
  ...nodes...   ctx.data=true (e.g. are linked in cascade)
    Coalesce  ctx.data=true (e.g. is a coalesce)

The link should not be continued (and the coalesce not removed) if the distribution is changed between the Coalesce->Sort cascade. Example:

SortExec ctx.data=false, to halt remove_bottleneck_in_subplan)
  AggregateExec  ctx.data=false, to stop the link
    ...nodes...   ctx.data=true (e.g. are linked in cascade)
      Coalesce  ctx.data=true (e.g. is a coalesce)