Skip to content

Cross-fragment (distributed) dynamic filters — optimizer placement + Runner aggregation #1566

Description

@mbasmanova

Problem

v2's multi-fragment plans lose the probe-side dynamic-filter reduction once the
probe is partitioned: Velox's runtime DF (hash-join build → probe TableScan)
does not cross an exchange, so once the probe is shuffled the reduction is gone.
At 4 workers this is a real regression:

  • q17 — subquery lineitem scan runs the full 60M rows vs. the single-node
    60M→61k reduction (sf10 +286%, sf1 +31%).
  • q9_alt — sf10 +22%.

Scope

Cross-fragment only: the target scan is separated from the join by ≥1 exchange
(partitioned join, or broadcast join with an upstream shuffle). The same-fragment
case (single-node, co-located/broadcast with no upstream probe shuffle) is already
handled by Velox's adaptive pushdown and is untouched.

Design

Plan of record: DistributedDynamicFilters.md (added in #1564).

Split of responsibilities:

  • Optimizer statically places each DF at plan time — producer join, consumer
    scan (via a filter-pushdown-legality walk through projects / aggregations on
    grouping keys / across the exchange), key mapping, bloom sizing from the total
    build estimate, and a selectivity/cost gate. Emits DF descriptors on the plan
    nodes and MultiFragmentPlan. One DF per join key.
  • Runner (LocalRunner) aggregates the build-side filters across tasks
    (collectAll → OR-union for partitioned, collectAny → first for broadcast;
    any opt-out → disable) and delivers the global filter to every pre-shuffle
    probe scan. No task talks to another; the filter flows Task → Runner → Task.
  • Velox exposes the per-task seam (tracked separately — see the Velox issue).

Work items

  • Optimizer: candidate marking at cross-fragment joins + static placement walk
    + cross-fragment gate; emit DF descriptors on MultiFragmentPlan and plan
    nodes.
  • LocalRunner: await producer filters, aggregate (union / first), opt-out →
    disable, deliver to consumer scans.
  • Velox seam: plan-node DF fields + three Task calls + TableScan wait
    (separate Velox issue).
  • Tests: Velox seam + Runner aggregation (unit); structural shape coverage
    (plan + results); e2e correctness (LocalRunner, DF on == off == single-node);
    perf.

Acceptance

q17 and q9_alt at 4 workers, sf1/sf10: reductions restored (q17 lineitem
60M→~61k), results unchanged, total-CPU regression closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions