Skip to content

r2il: bool_or/bool_and keep NULL apart from FALSE; COUNT(DISTINCT) excludes NULL keys (D-RFT-1 correction) - #1686

Merged
AdaWorldAPI merged 2 commits into
mainfrom
claude/eager-albattani-iufugq-rft1-null
Oct 21, 2026
Merged

AdaWorldAPI merged 2 commits into
mainfrom
claude/eager-albattani-iufugq-rft1-null

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Item B of the post-merge review of #1681 (GPT:gpt-ada-01/20261021-pr1674-1682-consolidated-review-01). I took it on the operator's instruction (EXO-50 /038). The original owner is session 01G22y, and the operator aligns afterwards.

Defects on main

  • bool_and(TRUE, NULL) answered 0, where PostgreSQL answers TRUE.
  • bool_or(NULL, NULL) answered 0, where PostgreSQL answers NULL.
  • count_distinct_sorted counted a run of NULL keys by their payload.

Change (crates/lance-graph-r2il/src/procs.rs)

bool_or and bool_and. New signature: bool_or(select, valid, flag) / bool_and(select, valid, flag).

  • Both fold over P = select ∧ valid.
  • Each pushes the value, then present. present == 0 is SQL NULL; the value is then 0 and is not FALSE.
  • bool_or = ANY(P ∧ T).
  • bool_and = present − ANY(P ∧ ¬T).

count_distinct_sorted. New signature: count_distinct_sorted(key_lane, valid).

  • It gates the selection on the key's presence plane before KEY_RUNS.
  • An unordered lane is still refused. Nothing is sorted or hashed.

All three stay R2IL procedures interpreted by FoldDialect and lowered to existing mask-risc operations. There is no new opcode or terminal, and no crate outside r2il calls these procedures.

Evidence

New tests in tests/procs.rs:

  • bool_aggregates_keep_null_apart_from_false covers the directive's six cases, each run again with every NULL payload scrambled:

    input bool_or bool_and
    TRUE, NULL TRUE TRUE
    FALSE, NULL FALSE FALSE
    TRUE, FALSE, NULL TRUE FALSE
    NULL, NULL NULL NULL
    empty selection NULL NULL
    FALSE, FALSE FALSE FALSE
  • count_distinct_excludes_null_keys_whatever_their_payload covers the first, middle and last runs, plus an all-NULL selection.

  • In the existing primitive test, the empty-selection expectation changes from (0, 1) to NULL.

Disable runs. Four, each red on its target test. Each removes valid from one place:

  • bool_or;
  • bool_and's FALSE fold;
  • the presence fold;
  • count_distinct_sorted.

PostgreSQL 16.15. Run with examples/null_aggs_pg_parity.rs, a lab instrument that prints SKIP without a server and does not count as CI parity.

  • 300 queries over 60 random tables: values and NULL states are equal.
  • The run includes 64 NULL bool aggregates and 12 cases of bool_and TRUE over a NULL row.
  • The disable arm (validity treated as every row) differs on 224.

Gates: r2il tests pass (9 dialect + 22 procs). Clippy --all-targets -D warnings and fmt are clean.

Board: a correction section is appended to entries/2026-10-21-d-rft-1-typed-composition.md.

Merge is attended: I will not merge this PR.


Generated by Claude Code

…cludes NULL keys

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
…try correction

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T22:11:25.223891Z 4230d26 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f024afe-7993-40e0-b4b1-03eb1d4c4533
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

AdaWorldAPI pushed a commit that referenced this pull request Oct 21, 2026
…correction #1686

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013z2e1YXkm6o6HNrDn5BPWA
@AdaWorldAPI
AdaWorldAPI merged commit d1b9c9d into main Oct 21, 2026
15 checks passed
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.

2 participants