Skip to content

feat: AVG skips SQL NULLs via per-column validity bitmap - #11

Open
VedantMadane wants to merge 1 commit into
basalt-db:mainfrom
VedantMadane:feat/avg-skip-nulls
Open

feat: AVG skips SQL NULLs via per-column validity bitmap#11
VedantMadane wants to merge 1 commit into
basalt-db:mainfrom
VedantMadane:feat/avg-skip-nulls

Conversation

@VedantMadane

Copy link
Copy Markdown

Summary

Scoped spike for #10: make AVG skip SQL NULLs using a per-column validity signal, without regressing the all-valid fast path.

What changed

  • Column::nullmask (+ is_null_at / set_null_at); empty mask = historical all-valid path
  • INSERT ... NULL marks validity (placeholder 0/"" still stored underneath)
  • AVG uses non-NULL count; all-NULL → SQL NULL
  • Vectorized global/fused agg paths honor the bitmap (or keep the tight loop when empty)
  • Docs: docs/NULL_AVG_SPIKE.md (covered vs TODO); pointer in GOOD_FIRST_ISSUES.md

Not in this PR (called out in the spike doc)

Disk-persisted validity, importer \N mapping, full SUM/MIN/MAX/COUNT(col)/WHERE three-valued logic, projecting NULL cells.

Test plan

  • make clean && make (Linux CI / native; this agent is Windows without mmap)
  • basalt-bench 1000000 50000 3 still all checks pass (no NULL bitmap on bench data)
  • Manual: INSERT mix of values + NULL, SELECT AVG(v) matches SQLite (20 for 10/NULL/30)

Related

Closes #10

Scoped NULL spike (basalt-db#10): mark explicit INSERT NULLs on Column::nullmask and
make AVG ignore them (divide by non-NULL count), keeping the empty-bitmap
fast path for importers/benches. Document coverage and remaining NULL work.

Closes basalt-db#10

Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Three-valued NULL handling for a single aggregate (spike)

1 participant