Repository navigation
Fix 41 analytic option rejections - #136
Merged
ohaibbq merged 7 commits intoNov 13, 2026
Merged
Conversation
…s analytic functions (Recidiviz#41) BigQuery refuses to plan STRING_AGG(DISTINCT x) OVER () and ARRAY_AGG(x IGNORE NULLS) OVER (); this engine returned a value for both. The rejection is per-function on the analytic path only: the GROUP BY aggregates keep DISTINCT and IGNORE NULLS, and other analytic aggregates (MIN, SUM, COUNT) keep DISTINCT. RESPECT NULLS emits no marker on the analytic path, so an explicit RESPECT NULLS cannot be distinguished from the default and is left alone.
Direct done() tests: STRING_AGG with DISTINCT errors with BigQuery's message, and the same frame without DISTINCT still aggregates duplicates; ARRAY_AGG with IGNORE NULLS errors, and without it the NULL stays in the array. SQL-level coverage via the new spec cases is left to CI: no system sqlite3 here, so the window.zig TestEnv suite cannot link locally.
Two error cases (STRING_AGG DISTINCT, ARRAY_AGG IGNORE NULLS over a window, with BigQuery's messages as expect_error substrings) plus controls showing both functions still work over a window without the rejected option. New cases are not in spec_baseline.txt; regenerate with --update-baseline once they pass in CI.
ohaibbq
requested changes
Nov 12, 2026
ohaibbq
left a comment
Member
There was a problem hiding this comment.
I think that these checks should be done at analyze/transform time, not at query runtime. A map of the odd duckling functions to which options they reject can live in just one place rather than be scattered across each window function's implementation
https://github.com/Recidiviz/zigquery/blob/main/src/internal/transformer/scan_analytic.zig
…iviz#41) Review feedback on PR Recidiviz#136: the STRING_AGG DISTINCT and ARRAY_AGG IGNORE NULLS rejections sat in each window function's runtime done(). They now live in one map in transformer/scan_analytic.zig (function -> rejected option pseudo-arg -> BigQuery message) and are checked while the analytic scan is transformed, so a rejected query fails translation with BigQuery's message and never reaches the runtime. The fn_window done() implementations keep honoring the options if a call does reach them; their unit test asserts that instead of the rejection. New transformer tests cover both rejections at translate time plus controls (plain STRING_AGG / ARRAY_AGG, ARRAY_AGG DISTINCT, SUM DISTINCT). Checks: zig build test 592/592, zig build test-server pass, spec-runner analytic_option_rejections 4/4 PASS, zig fmt --check clean.
Contributor
Author
|
Done — moved the checks to transform time. |
ohaibbq
requested changes
Nov 13, 2026
ohaibbq
left a comment
Member
There was a problem hiding this comment.
Looks a lot better! Could you have your claude follow the comment styles laid our in AGENTS.md?
Thank you!
Follow-up on the Recidiviz#136 review: fn_window.zig drops out of the change entirely (the window .zon specs cover that behavior), the scan_analytic tests call checkAnalyticOptionRejections directly instead of translating whole queries, and the comments state the rule briefly per AGENTS.md. Checks: zig build test, zig build test-server, spec-runner analytic_option_rejections 4/4 PASS, zig fmt clean.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ohaibbq
enabled auto-merge (squash)
November 13, 2026 18:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #41
What BigQuery does
What the emulator did
Spec cases
Checks
zig build testzig build test-serverzig build spec -- --strictzig fmt --check build.zig entrypoints tools