Skip to content

fix(query): accept Bool, Date, and DateTime in min and max - #637

Merged
azimafroozeh merged 2 commits into
ModernRelay:mainfrom
azimafroozeh:min-max-over-date-and-bool
Sep 5, 2026
Merged

azimafroozeh merged 2 commits into
ModernRelay:mainfrom
azimafroozeh:min-max-over-date-and-bool

Conversation

@azimafroozeh

Copy link
Copy Markdown
Contributor

What & why

Closes #623. min($p.birthdate) over a Date column was refused at typecheck (T8: min requires numeric or string type, got Date?), and DateTime and Bool columns the same way; only numeric and String columns passed, and the executor had arms for those alone. Found converting Kuzu's aggregate tests to .gqt cases.

  • The T8 rule for min/max keys on one predicate naming the accepted scalars (numeric, String, Bool, Date, DateTime) and its message lists them; lists, vectors, and Blob values stay refused.
  • The executor gains Boolean, Date32, and Date64 arms through the existing typed min/max path (false before true, dates chronological); the result keeps the column's own type, as before.
  • The zero-row shortcut that typed every non-count aggregate as a Float64 null is deleted: an all-aggregate query over zero matched rows now flows through grouping as one empty group, so count is 0 and min/max return a null of the column's own type; sum and avg still build Float64.
  • Case issue_623_min_max_over_date_and_bool.gqt: one accept step over all three column types, a zero-row step and a null-only-row step whose --- expect shape blocks pin the result types through the schema check from test(gq): add a mandatory --- expect shape section and a result-schema check #635, and four refusal steps (min over a list, max over a Vector, sum over a Date, min over a Blob).

Backing issue / RFC

Checklist

  • Change is focused (one typecheck predicate, three executor arms, and the zero-row builder that contradicted the declared type)
  • Tests added/updated for behavior changes (the .gqt case, 7 steps: accept, zero rows, null-only row, four refusals; result types via --- expect shape; no Rust test, nothing the format cannot express)
  • Public docs updated if user-facing surface changed (docs/user/queries/index.md: accepted types, ordering, zero-row shape; docs/releases/v0.11.0.md: Highlights bullet)
  • Reviewed against docs/dev/invariants.md — no Hard Invariant weakened, no deny-list item hit (typecheck and projection only; no storage, commit, or policy path touched)

Local verification

  • cargo test -p omnigraph-gqt — 116 unit + 12 cases green on 50f3a6bc (the new case: 7 steps)
  • cargo test -p omnigraph-compiler — 332 green
  • cargo test -p omnigraph-engine --test aggregation — 8 green
  • cargo clippy --workspace --all-targets — green
  • cargo fmt --all --check — clean
  • python3 scripts/check-docs.py — 126 files OK
  • cargo test --workspace — run on the previous base 9570c7a7: lib 403 passed / 1 failed (external_blob_file_policy_rejects_special_files, a known failure under the dev-machine sandbox), 45 integration binaries green; not rerun on 50f3a6bc

Notes for reviewers

  • Behavior change beyond the accept set: over zero matched rows an all-aggregate query's min/max columns are now typed as the column, not Float64. A JSON row omits a null cell's key, so the difference shows only in the Arrow IPC result schema from feat: unify graph JSON output on one Arrow writer and offer Arrow IPC as a query result format #627.
  • The deleted zero-row builder was a second producer of that row shape; the grouping path already builds it, and a no-match query that also projects a group value still returns zero rows (stated in the user doc).
  • Bool in min/max follows Kuzu, Neo4j, DuckDB, and Memgraph; PostgreSQL refuses it and offers bool_and/bool_or instead.
  • Pre-existing and out of scope: the T8 rule consults the accept set only for scalar arguments, so min($p) over a node variable still typechecks and orders the id string.
  • Drive-by in the same user-doc paragraph: the stray '''''' left by fix(compiler): refuse two projections that execute to one result column name #621 is removed.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@azimafroozeh
azimafroozeh merged commit 02d182b into ModernRelay:main Sep 5, 2026
23 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.

bug: min and max refuse Date and Bool columns

1 participant