Skip to content

fix: refuse COUNT over a qualified or modified star - #121

Merged
kvlonge merged 2 commits into
mainfrom
fix/count-star-modifiers
Nov 6, 2026
Merged

kvlonge merged 2 commits into
mainfrom
fix/count-star-modifiers

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Why

COUNT over a qualified or modified star converted to count(*), which counts every row. Snowflake counts other rows for these shapes: C's held receipts show COUNT(alias.) giving 3, and COUNT( EXCLUDE …) and COUNT(* ILIKE …) giving 4, where count(*) gives 5. That is a wrong answer. Until a conversion is recorded for each shape, they refuse.

Changes

  • COUNT refuses (SQ0003 fn:COUNT) over a qualified star (t.*) and over a star with EXCLUDE, ILIKE, RENAME or REPLACE, including DISTINCT and windowed forms. COUNT(*), COUNT(x), COUNT(DISTINCT x) and COUNT(DISTINCT x, y) are unchanged.
  • The call spelling of COUNT treats only a bare * as COUNT(*).
  • The COUNT rule's conditions say so.

Other calls over a star were checked and need no change. ARRAY_AGG, OBJECT_AGG, MAX, SUM, MIN_BY, ANY_VALUE, COUNT_IF, HASH_AGG, APPROX_COUNT_DISTINCT, LISTAGG and ARRAY_UNIQUE_AGG over a qualified or modified star already refuse. OBJECT_CONSTRUCT, HASH and ARRAY_CONSTRUCT expand the star themselves, honour EXCLUDE, and refuse ILIKE, RENAME and REPLACE.

Verification

  • A CLI test converts each of the seven shapes (t.*, EXCLUDE, ILIKE, RENAME, t.* with EXCLUDE, DISTINCT t.*, and t.* over a window) and checks that it refuses.
  • make check-ci, make test-rust and make verify-recorded.

COUNT(t.*), COUNT(* EXCLUDE ...), COUNT(* ILIKE ...), COUNT(* RENAME ...),
COUNT(DISTINCT t.*) and their windowed forms converted to count(*), which
counts every row. Snowflake counts other rows for them, so they refuse
until recordings show what to convert them to.
kvlonge added a commit that referenced this pull request Nov 6, 2026

kvlonge commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Gate at 144dc45 (based on main 287f275):

  • make check-ci: exit 0
  • make test-rust: exit 0
  • make verify-recorded: 11,779 cases, 0 failed; translation baseline unchanged, nothing regressed
  • Hygiene scan: clean
  • One-round audit: approved, nothing to change. Every modified-star COUNT spelling probed now refuses, and COUNT(), COUNT(a), COUNT(DISTINCT a[, b]) and windowed COUNT() are unchanged.

The hosted CI run did not start (Actions billing), so this local gate stands in for it.

kvlonge commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Landing gate at 596399e (main 05c97e7 merged):

  • make check-ci: exit 0
  • make test-rust: exit 0
  • make verify-recorded: 11,793 cases, 0 failed; nothing regressed
  • Hygiene scan: clean
  • One-round audit: approved (d6f40d5)

@kvlonge
kvlonge merged commit 596399e into main Nov 6, 2026
1 check failed
@kvlonge
kvlonge deleted the fix/count-star-modifiers branch November 9, 2026 21:31
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.

1 participant