Skip to content

Join per-column stats not scaled with estimated row count #22761

@neilconway

Description

@neilconway

Describe the bug

For inner/left/right/full joins, estimate_join_cardinality concatenates both inputs' column statistics verbatim and never adjusts them to the estimated output cardinality:

  • Count-like fields (null_count, distinct_count, byte_size, sum_value) aren't scaled to the join's fan-out/selectivity, so they can be inconsistent with the output num_rows.
  • Outer joins don't NULL-pad the non-preserved side, even though the side-to-pad is already known (utils.rs:240-242).
  • Equi-join key columns aren't intersected (min/max) or NDV-bounded (min(left_ndv, right_ndv)).

Related to #22743 but the general join case might be a bit more involved.

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions