Skip to content

Fix composite histogram key types with NULL components - #393

Merged
KKould merged 1 commit into
mainfrom
fix/histogram-null-key-types
Oct 26, 2026
Merged

KKould merged 1 commit into
mainfrom
fix/histogram-null-key-types

Conversation

@KKould

@KKould KKould commented Oct 26, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

The sql_exec fuzz smoke test panics at histogram.rs:699: on a composite index, a NULL component reports SqlNull, so a bucket ending at (NULL, x) fails debug_assert_eq!(Tuple([Integer, Integer]), Tuple([SqlNull, Integer])). The same strict comparison also made endpoint_count skip keys with NULL components.

Issue link:

What is changed and how it works?

  • Add key_types_match: tuple components match when either side is SqlNull; other types still compare exactly.
  • Use it for the bucket assertion and for the endpoint type check in endpoint_count.

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

Repro: index (a, b) with some a IS NULL rows, analyze, then select count(*) from t where a < 193 panics in debug builds. test_endpoint_count_uses_only_full_histogram_keys now covers both cases. The assertion dates from #354; only estimates were affected, not query results.

@KKould KKould self-assigned this Oct 26, 2026
@KKould KKould added the bug Something isn't working label Oct 26, 2026
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.39%. Comparing base (55e0820) to head (1ae4aee).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #393   +/-   ##
=======================================
  Coverage   93.39%   93.39%           
=======================================
  Files         272      272           
  Lines       39076    39089   +13     
=======================================
+ Hits        36495    36508   +13     
  Misses       2581     2581           
Flag Coverage Δ
rust 93.39% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/optimizer/core/histogram.rs 94.22% <100.00%> (+0.15%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KKould
KKould merged commit a85b7d3 into main Oct 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant