Skip to content

Commit a9400ce

Browse files
committed
docs: update JoinStatisticsProvider comments to reflect NLJ delegation
1 parent 051d557 commit a9400ce

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • datafusion/physical-plan/src/operator_statistics

‎datafusion/physical-plan/src/operator_statistics/mod.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
//! 2. [`ProjectionStatisticsProvider`] - column mapping through projections
4646
//! 3. [`PassthroughStatisticsProvider`] - passthrough for cardinality-preserving operators
4747
//! 4. [`AggregateStatisticsProvider`] - NDV-based GROUP BY cardinality estimation
48-
//! 5. [`JoinStatisticsProvider`] - NDV-based join output estimation (hash, sort-merge, nested-loop, cross)
48+
//! 5. [`JoinStatisticsProvider`] - NDV-based join output estimation (hash, sort-merge, cross); nested-loop delegates to built-in
4949
//! 6. [`LimitStatisticsProvider`] - caps output at the fetch limit (local and global)
5050
//! 7. [`UnionStatisticsProvider`] - sums input row counts
5151
//! 8. [`DefaultStatisticsProvider`] - fallback to `partition_statistics(None)`
@@ -738,13 +738,16 @@ impl StatisticsProvider for AggregateStatisticsProvider {
738738
}
739739
}
740740

741-
/// Statistics provider for all join types (hash, sort-merge, nested-loop, cross).
741+
/// Statistics provider for equi-joins (hash join, sort-merge join) and cross joins.
742742
///
743-
/// For equi-joins (hash join, sort-merge join), estimates output cardinality as
743+
/// For equi-joins, estimates output cardinality as
744744
/// `left_rows * right_rows / product(max(left_ndv_i, right_ndv_i))`
745745
/// across all join key columns (assuming independence between keys),
746746
/// falling back to the Cartesian product when any key lacks NDV on both sides.
747-
/// For nested-loop and cross joins, uses the exact Cartesian product.
747+
/// For cross joins, uses the exact Cartesian product.
748+
/// Nested-loop joins delegate to the built-in `partition_statistics` since an
749+
/// arbitrary `JoinFilter` can be highly selective and the Cartesian product
750+
/// would overestimate.
748751
///
749752
/// The base inner-join estimate is then adjusted for the join type:
750753
/// - Semi joins: capped at the preserved-side row count

0 commit comments

Comments
 (0)