Skip to content

Commit bcc68fd

Browse files
committed
fix: address review feedback for fallback selectivity heuristic
Rework compute_fallback_selectivity to resolve all issues raised by @asolimando: 1. Default selectivity is now applied at most once for all unhandled conjuncts combined, instead of multiplied per-conjunct. A predicate with three unhandled terms (e.g. LIKE, <>, IN) stays at 0.2, not 0.2^3 = 0.008. 2. For col_a = col_b equalities, use 1/max(NDV(left), NDV(right)) instead of only considering the left side's NDV. 3. Restore tests that were accidentally removed during the merge with main (fetch_preserves_singleton, fetch_statistics_match_execution, fetch_null_column_statistics, singleton_precision). 4. Add unit tests for compute_fallback_selectivity covering: - single handled equality (1/NDV) - several unhandled conjuncts (default applied once) - mixed handled and unhandled (1/NDV * default) - col = col with max(NDV) - non-equality predicate (default only) - CAST(col) = expr (not handled, shows current behavior) - utf8 col = literal (handled via NDV) 5. Add SLT plan test with scalar subquery equality showing the new row estimate. Note: utf8_col = 'literal' also fails check_support, so it now gets 1/NDV instead of 20%. This is generally more accurate since a Utf8 column with 60 distinct values should estimate ~1.7% selectivity for an equality match, not a blanket 20%.
1 parent 6a98497 commit bcc68fd

2 files changed

Lines changed: 645 additions & 77 deletions

File tree

0 commit comments

Comments
 (0)