Skip to content

feat(birdbench): add Snowflake dialect, graded on a local stand-in - #6483

Open
abelatnvidia wants to merge 29 commits into
NVIDIA-NeMo:mainfrom
abelatnvidia:abel/birdsnowflake-pr
Open

abelatnvidia wants to merge 29 commits into
NVIDIA-NeMo:mainfrom
abelatnvidia:abel/birdsnowflake-pr

Conversation

@abelatnvidia

@abelatnvidia abelatnvidia commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Review prompts/default_snowflake.yaml, the new config fields in bird_sql/app.py, the Snowflake half of eval_utils.py (snowflake_rejection and the executor), and setup_bird_snowflake.py (the stand-in build, the read-only role and the startup visibility check). Skip the tests, snowflake_gold_check.py and snowflake_load_account.py. Laid out like the Spark and PostgreSQL dialects (#6063). Push history is in the comments.

Adds --dialect snowflake to the BIRD benchmark, next to sqlite, spark and postgres. By default the model's Snowflake SQL runs on fakesnow, a local stand-in that runs Snowflake SQL on DuckDB, so no account is needed. The gold SQL runs untouched on SQLite and the two results are compared, as for the other dialects. Calibrated on a real Snowflake account (BIRD dev): the stand-in and Snowflake agree on pass or fail for 1,498 of 1,532 translated gold queries (97.8%), and for 1,523 of 1,532 of a model's own answers (99.4%, Nemotron 3.5 Lightning).

  • Server (dialect: snowflake): builds a read-only DuckDB copy of the BIRD databases on first start (dev: about 16 s, 850 MB), keeping BIRD's names, created quoted so they're case-sensitive as on Snowflake. DuckDB's file and network access is off and locked.
  • A static check runs before each query, because DuckDB accepts things Snowflake refuses: anything but a single query, identifiers that don't resolve under Snowflake's case rules, SQLite-only spellings, and a few DuckDB-only functions and constructs. On the account, Snowflake refused every query the check refuses, and the check refused none of the 2,681 distinct queries Snowflake ran.
  • Verifier failures are masked, as in feat(birdbench): add PostgreSQL dialect #6063: a lost or failed connection, an engine I/O or internal error, or a setup that takes over two minutes is a verifier error; anything else the query raises is the model's error.
  • Real accounts: snowflake_engine: snowflake grades on an account through a named connector connection; no credentials go in Gym's config. The verifier connects as a read-only role with secondary roles off, and startup fails if that role can't see a table.
  • prepare and eval.sh: schema-qualified, double-quoted names and Snowflake column types. The prompt is the PostgreSQL prompt with the engine changed.
  • Dependencies: fakesnow==0.12.1 and snowflake-connector-python<5, locked dependencies of bird_sql only, loaded only for dialect: snowflake. Everything they add to the lock is MIT or Apache-2.0 (licenses in the bird_sql README; one metadata inconsistency in fakesnow is raised in a comment).
  • Limits: the stand-in differs from Snowflake in known ways, listed in the READMEs with a per-question exclusion list (dev, default version).

Open question, identifier case (default: keep BIRD's mixed-case names, quoted). Upper-casing them, as #6063 lower-cased PostgreSQL's columns, would let unquoted names resolve (the check refused 209 of Lightning's 1,532 answers for case; 208 of them write the name unquoted), but it changes the loader, prepare, the gold check and the account layout: a follow-up.

Validation

  • bird_sql tests at this head: 224 passed, 31 skipped (the PostgreSQL tests; no PostgreSQL server here). With local PostgreSQL 16 and Spark, 255 passed at 8a48e65df93bae1b589fbe32498e5e93b73e7acc, before this merge with main; not rerun since. birdbench tests: 116 passed, 6 skipped (the BM25 tests, without bm25s; with it, test_build_db_values.py passes 54 of 54). A copy of the Snowflake sql_context test runs in CI from tests/unit_tests/benchmarks/.
  • snowflake_gold_check.py on dev: 1,413 of 1,534 golds match on the stand-in, 1,439 on the account. A rerun of the same check on a fresh clone with a freshly built stand-in gave the same result, question by question. The 121 that don't match on the stand-in are classed in failures_by_class.json.
  • eval.sh --dialect snowflake on all of dev with a stub model that answers the translations: the same 1,413 questions pass.
  • Merged with main (with feat(birdbench): add BIRD's 2025-11-06 dev and both Mini-Dev releases as dated versions, and a schema-only prompt #6711), and merging cleanly with today's main: uv lock --check, the component-lock check, the secrets detector and pre-commit pass.

Rollouts

Nemotron 3.5 Lightning on all of dev (thinking on for every request, temperature 0, 16,000 max output tokens): pass@1 51.96% on the stand-in, 51.50% on a real account.

Compatibility and benchmark impact

The defaults for sqlite, spark and postgres are unchanged, but two lock changes reach every dialect: fakesnow requires sqlglot~=30.22.0, so the bird_sql lock moves sqlglot from 30.33.0 to 30.22.0, and botocore, through the connector, moves python-dateutil from 4.0.0 to 2.9.0.post0. The Spark and PostgreSQL tests passed on both (the 255 above).

A Gym maintainer merges after an approving review, as for #6063.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

🤖 Generated with Claude Code

abelatnvidia and others added 3 commits November 19, 2026 11:30
dialect: snowflake grades a model's Snowflake SQL. With the default
snowflake_engine: fakesnow there is no Snowflake account behind it:
fakesnow transpiles the query with sqlglot and runs it on DuckDB, over
a read-only copy of the BIRD databases that the server builds on first
start (one schema per db_id, BIRD's names created quoted, Spark's
column typing). The gold stays the untouched SQLite query and only the
result sets are compared, as for Spark and PostgreSQL.

DuckDB accepts things Snowflake refuses, so a static check runs first:
a single query only, identifiers resolved by Snowflake's rules
(unquoted means upper case, including JOIN ... USING names, and a
table-qualified name must be a real column, not a select alias), and
no SQLite-only spellings such as IIF or LIMIT a, b. DuckDB's file and
network access is off and locked, so model SQL can't read files
through table functions such as read_csv. Timed-out queries are
interrupted, queries run single-threaded so float sums are
repeatable, and rows are read by position because fakesnow's
fetchall() drops one of two same-named columns.

As for PostgreSQL, a failure of the engine or its connection (SQLSTATE
class 08 and the other infrastructure classes, DuckDB I/O errors)
raises and masks the row as a verifier error; anything else the query
raises, including a value Python can't hold, scores as the model's
error. Each load records a layout version, and startup refuses a
BIRD.db built with another layout.

snowflake_engine: snowflake points the same grader at a real account
that already holds the data, through a named connection in the
connector's connections.toml. It has not run against an account yet.

fakesnow==0.12.1 and snowflake-connector-python<5 are locked
dependencies of bird_sql, like pyspark and psycopg. The pin is exact
because the grader reads two private fakesnow attributes, and fakesnow
0.12.1 doesn't import with connector 5.x. fakesnow requires sqlglot
~=30.22.0, so the lock moves sqlglot from 30.30.0 to 30.22.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…ld check

prepare renders the schema with schema-qualified, double-quoted names
in BIRD's case and the Snowflake column types the stand-in loads; it
needs only pandas. The prompt is the PostgreSQL one with the engine
changed. Its sentence asking for every name double-quoted exactly as
shown holds on Snowflake, which folds unquoted names to upper case.
eval.sh passes the dialect and, for train, its own stand-in directory.

snowflake_gold_check.py grades sqlglot transpiles of the golds with
the server's own comparison. On dev, 1,430 of 1,534 (93.2%) match
after one mechanical fix, identifier case (a second fix, double-quoted
names to strings, fires on no dev gold). None match without the case
fix: the identifier check refuses them, although DuckDB alone would
run them.

Each gold that doesn't match gets a failure class, and
failures_by_class.json lists the question ids of each class, numbered
as prepare numbers them, so that whoever validates generated training
SQL on the stand-in can leave those questions out. --split train
checks the train uberset. The README says where the stand-in passes
wrong Snowflake SQL or fails correct SQL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
The tests load a small schema into a temporary BIRD.db and need no
account or server. They cover routing and engine selection, the static
check, the loader and its layout check, grading (identifier case,
same-named columns, LIKE versus ILIKE, timeouts, refused statements, a
read-only stand-in), and the split between query faults and engine
failures, including 'infinity'::date and a closed connection. They
also cover the gold check's failure classes. prepare's Snowflake
rendering is covered in birdbench.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Nov 19, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:high Autobot PR risk: high feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer labels Nov 19, 2026
abelatnvidia and others added 4 commits November 20, 2026 09:26
A user's default secondary roles are often ALL. A session that names a
read-only role then still holds every other role the user has, and can
write through them: on a real account, a session as a SELECT-only role
could INSERT, DELETE and DROP through SYSADMIN, and could see every
database. Each connection of the snowflake engine, including the one
that checks the loaded data at startup, now runs
USE SECONDARY ROLES NONE, so only the connection's own role applies.
A connection where that fails is closed and the error raised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
On a real account, 17 translated dev golds matched on the stand-in but
failed on Snowflake, which refuses SUM/AVG of a boolean (SUM("x" = 'y'),
10 golds) and a SELECT DISTINCT ordered by something it doesn't select
(7). DuckDB runs both. The static check now refuses them too, including
an IFF, CASE or COALESCE whose results are all booleans, an ORDER BY
column qualified by another table, and an ORDER BY column the select
list only uses inside an expression. It stays conservative: a number
in between (IFF(c, 1, 0), CAST, COUNT_IF), a selected column, alias,
position or expression, an expression built from selected columns,
SELECT DISTINCT * and aggregates in the ORDER BY are left alone. A
SUM(DISTINCT) with no argument is unparsable instead of an IndexError
that would mask the answer as a verifier error.

Rechecked against every saved Snowflake outcome: of 3,105 distinct
queries, the check refuses none of the 1,477 Snowflake ran, and 29 live
edge cases matched what Snowflake does. No input made it raise in a
fuzz over 39,023 cut-off queries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
The BIRD dev databases were loaded into a Snowflake account in the
layout check_bird_snowflake_account expects, and the gold check was run
there through a read-only role. snowflake_gold_check.py takes
--snowflake-connection NAME to grade on such an account instead of the
stand-in.

On dev, sqlglot's translations of the golds match on 1,439 of 1,534 on
Snowflake and 1,413 on the stand-in; the two agree on pass or fail for
1,498 of the 1,532 whose gold runs on SQLite (97.8%). The READMEs now
give these numbers and replace the guesses with what the account did:
- Date functions on the VARCHAR date columns: YEAR, MONTH, EXTRACT and
  DATE_PART fail on Snowflake too. Only DATEDIFF and DATEADD on a
  string run on Snowflake and fail on the stand-in.
- Text arithmetic: Snowflake casts it (20 of 24 such golds match).
- Every query the static check refuses, Snowflake refuses too.
- DuckDB-only functions, TO_CHAR of a VARCHAR with a format and
  division by zero run on the stand-in and fail on Snowflake.
The gold check's failure classes carry the measured outcomes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
snowflake_engine: snowflake needs the data already loaded in the exact
layout check_bird_snowflake_account reads, and nothing produced it.
load_bird_snowflake_account loads every missing db_id through an admin
connection: the same schemas, quoted names and column types as the
stand-in, written with write_pandas into explicit DDL. Snowflake
commits DDL on its own, so a db_id's loaded row is written last, after
every table's row count matches SQLite, and its schema is dropped if
the load fails.

On a shared account a schema named like a db_id may be someone else's,
so the loader marks the schemas it creates with a comment and replaces
only those; any other schema of that name stops the load ("drop it
first"). It grants the grader's read-only role USAGE and SELECT on each
db_id right after loading it, and again on every run: FUTURE grants
need MANAGE GRANTS, which a database owner such as SYSADMIN usually
lacks. The admin connection keeps the user's secondary roles on
purpose. check_bird_snowflake_account now raises when the grader's
role can't see a db_id's tables, which would otherwise refuse every
query on it as an unknown table and score it 0.

benchmarks/birdbench/snowflake_load_account.py runs it once from the
command line; the bird_sql README gives the account setup. On a real
account, dev loads in about 7 minutes and the loaded catalog equals
the stand-in's (798 columns, every type). The tests use a fake
connection; no account is needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Pushed four commits on top of what was here (no force push). They come from running the grader on a real Snowflake account, on BIRD dev:

  • The stand-in and Snowflake agree on pass or fail for 97.8% of the translated gold queries (1,498 of 1,532). The description has the breakdown.
  • Two fixes from that run. Grader connections now turn off the user's default secondary roles: with them on, a read-only role could still write through the user's other roles. And the static check now refuses SUM/AVG of a boolean and a SELECT DISTINCT ordered by something it doesn't select; Snowflake refuses both, and the stand-in passed them.
  • snowflake_load_account.py loads an account for snowflake_engine: snowflake. It replaces only schemas it created, and the server now refuses to start if its role can't read a database.
  • The READMEs give measured results instead of guesses. One guess was wrong: YEAR and EXTRACT on the VARCHAR date columns fail on Snowflake too, so they aren't a stand-in gap.

Nothing changed for sqlite, spark or postgres. Happy to walk through it in 15 minutes.

@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 20, 2026
abelatnvidia and others added 2 commits November 20, 2026 15:00
Brings the branch up to date with main. The only conflict was
resources_servers/bird_sql/uv.lock, which main's lock upgrade (NVIDIA-NeMo#6528)
rewrote. Resolved by taking main's lock and re-locking with uv 0.13.4,
the version CI uses: every version main locks is kept, and the
Snowflake dependencies are added at the versions this PR already
tested (fakesnow 0.12.1, snowflake-connector-python 4.8.1, duckdb
2.0.0, boto3 and botocore 1.44.5, and their dependencies). Two of
main's versions move down because those dependencies require it:
sqlglot 30.33.0 -> 30.22.0 (fakesnow pins ~=30.22.0, as before) and
python-dateutil 4.0.0 -> 2.9.0.post0 (botocore requires <3, through the
Snowflake connector). scripts/component_locks.py passes for all 327
managed projects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…ctions

Calibrating the stand-in on a model's own Snowflake SQL (Nemotron 3.5
Lightning, all of dev) against a real account found 14 answers that
pass on the stand-in and fail on Snowflake. Six were SQL Snowflake
doesn't have: an aggregate FILTER (WHERE ...) clause (5) and DIVIDE()
(1), which DuckDB runs. The static check now refuses the FILTER clause
and six DuckDB-only functions, each one an unknown function on an
account: DIVIDE, EPOCH_MS, LIST_VALUE, REGEXP_MATCHES, STRING_AGG and
STRPTIME. Snowflake's own FILTER(array, lambda), DIV0 and LISTAGG stay
allowed. Function names are matched as written, like the SQLite-only
list: a quoted name or a query with a CTE of the same name gets past,
and a table alias with a column list of that name is refused; the
READMEs say so.

Rechecked against every saved Snowflake outcome (gold translations,
probes and the model's answers): of 4,614 distinct queries, the check
refuses none of the 2,681 Snowflake ran, and 37 hand-written edge cases
of the check, run live on the account, give the same verdict as
Snowflake. On the model's answers, agreement between the stand-in and
Snowflake goes from 99.0% to 99.4% (1,523 of 1,532); the gold check is
unchanged. The READMEs give the model-output result and document what
remains: five ratios where Snowflake's fixed-point division changes the
sixth decimal, a precision limit the check can't see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Pushed two more commits (no force push):

  • A merge of main, to clear the conflict in resources_servers/bird_sql/uv.lock after main's lock upgrade (build(deps): upgrade all managed dependency locks #6528). I re-locked from main's lock with uv 0.13.4: main's versions are kept, except sqlglot (fakesnow needs 30.22) and python-dateutil (botocore needs <3).
  • A fix from running a real model on this dialect. Nemotron 3.5 Lightning answered all of BIRD dev, and each answer was graded on the stand-in and on a real Snowflake account. They agreed on pass or fail for 99.0%. Six of the 14 answers that passed only on the stand-in used SQL Snowflake doesn't have (an aggregate FILTER (WHERE ...) clause, and DIVIDE()), so the static check now refuses those. Agreement is now 99.4% (1,523 of 1,532). Of the 8 that still pass only on the stand-in (plus 1 that passes only on Snowflake), 5 are a precision limit: Snowflake's fixed-point division changes the sixth decimal of a ratio. The description has the breakdown.

Nothing changed for sqlite, spark or postgres.

abelatnvidia and others added 10 commits November 21, 2026 19:24
Brings the branch up to date with main, which now carries NVIDIA-NeMo#6534
(sanitized Spark table names). One conflict, in the DbHandle docstring
of benchmarks/birdbench/build_db_values.py: NVIDIA-NeMo#6534 rewrote the Spark
sentence (tables named as Spark loads them) and this PR appended the
Snowflake one; both are kept. The code merged cleanly: NVIDIA-NeMo#6534's
_table_name hook is the identity for Snowflake, which keeps BIRD's
names, and its is_prepared_data_current() only checks Spark files.
eval.sh, prepare.py and the build_db_values tests auto-merged. Main
changes no lock this PR touches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
The Snowflake connector gives an error without a SQLSTATE the
placeholder "n/a". That string is truthy, so a failed request
(OperationalError 250003) was judged by it, read as the query's
fault, and scored as an unmasked 0. Now "n/a" counts as no SQLSTATE,
and an OperationalError or InterfaceError without one is an engine
failure, re-raised and masked as a verifier error, as psycopg's are
for PostgreSQL. A ProgrammingError without one is still the query's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
fakesnow keeps every completed query's Arrow result, SQL and AST in a
results_cache shared by all of an instance's connections (it serves
RESULT_SCAN), and closing a connection does not free them, so the
stand-in's memory grew with every graded query. LocalSnowflake's
fetch_all now drops its own query's entry once the rows are read,
leaving other connections' entries alone. The grader reads each result
exactly once, so nothing that reads the cache later is lost.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
The static check refused two shapes of query that Snowflake runs
(checked on a real account):
- A comment after the last semicolon (SELECT 1; -- why). sqlglot
  returns it as a separate Semicolon node, which the check counted as
  a second statement. Comment-only nodes are no longer counted; a real
  second statement still is.
- JOIN ... USING (k) where k is a column the joined CTEs or derived
  tables output. USING names were checked against catalog columns
  only; they are now checked against the query's output columns too,
  so an unquoted name the catalog lacks in that case is still refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
When the timeout fired while snowflake.connect() was still running in
the worker thread, nothing was interrupted (the connection didn't
exist yet), the semaphore slot was released at once, and the worker
then connected and ran the query anyway, outside the concurrency bound.
execute_snowflake_async now tells the worker to stop (a worker that
finishes connecting after the timeout closes the connection without
running the query), interrupts the query again until the worker thread
has stopped, and only then releases its semaphore slot. The test runs
three queries whose connect outlasts the timeout under a semaphore of
one: none runs, and no two overlap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
Four static-check gaps from review, each checked on a real account:
- An alias no longer vouches for a wrong-case column inside its own
  definition: MAX(height_cm) AS height_cm passed and ran on the stand-in;
  Snowflake says invalid identifier. Aliases used in WHERE, ORDER BY or
  a later select item are still fine.
- A column must belong to its own table, not to any table of the schema:
  foreign_data."multiverseId" passed because cards has that column.
  Qualified columns are checked against their table; unqualified ones
  against the catalog tables in scope (or an enclosing scope, for a
  correlated subquery), and only when every source in reach is a
  catalog table.
- A bare function in FROM, such as DuckDB's range() or query() (which
  runs any SQL), is refused: Snowflake gives a syntax error there, and
  its own table functions, wrapped in TABLE() or LATERAL, are unaffected.
- VALUES rows output COLUMN1, COLUMN2, ...; selecting them was refused
  though Snowflake runs it.

Of 4,614 saved queries with a Snowflake outcome, the check still refuses
none of the 2,681 Snowflake ran, and now refuses 15 more of those it
failed. 20 review cases and the 37 earlier edge cases run live on the
account all behave as Snowflake does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
The timeout clock started when the coroutine handed the work to a
thread, so it also counted waiting for a free worker thread, the static
check and, on an account, the login. On a busy server a query that
takes milliseconds alone took 4.5 s, and a timeout is scored as the
model's 0. The clock now starts when the query is sent. Getting there
taking over two minutes raises instead, as the engine's failure, which
verify masks. On an account, whose server stops the query itself at
its statement timeout, the client waits 10 s longer, so the timeout is
the server's verdict rather than a race with it.

Stopping a timed-out query moves into one helper, which interrupts it
again every second until the worker thread is done: DuckDB drops an
interrupt sent before the query starts (for example while fakesnow
transpiles), and the query would otherwise run on with no limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
Turning a query's result into Python rows can't be interrupted. A
model query returning 30 million rows ran 14 s past its 1 s timeout
on the stand-in, holding a worker thread and memory. Both engines now
check the row count first: a result over 5,000,000 rows (18 times the
largest BIRD dev gold result, 278,230 rows) is not converted, or, from
an account, not downloaded, and scores as the query's failure. The
stand-in still frees its cached result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
The startup check caught a db_id only when its role could see none of
its tables. One table missing its grant still refused every model query
on it as an unknown table, scored 0. The check now compares the tables
the grader's role can see with each SQLite file's tables and names
every one it can't see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…count behavior

The READMEs now say what the review fixes changed and what they leave:
columns resolve per table and an alias doesn't cover its own
definition; a bare function in FROM is refused; a query's timeout
counts from when it starts and its slot is held until its thread
stops; results over 5,000,000 rows aren't converted; startup checks
every table. On an account, TABLE(...) functions such as
QUERY_HISTORY() pass the static check and are contained by the
read-only role, and each query logs in again, so the connection needs
non-interactive authentication and adds about a second per query
outside the timeout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Pushed 10 more commits (no force push): a merge of main and fixes from two reviews of the grader.

  • The merge brings in fix(birdbench): sanitize Spark table names #6534 (sanitized Spark table names). Its one conflict was a docstring in build_db_values.py, where both sentences are kept; nothing changes for Snowflake.
  • Scoring: a network error on an account is now a masked verifier error, not a 0. A query's timeout counts from when it starts, so waiting for a thread or a login no longer turns a fast answer into a timeout. A timed-out query is stopped and holds its slot until its thread ends. A result over 5,000,000 rows isn't converted.
  • The static check follows Snowflake more closely, and each change was checked on a real account. A column must belong to its own table, and an alias no longer covers a wrong-case column inside its own definition. DuckDB's bare table functions such as query() are refused. VALUES columns, a comment after the last semicolon, and USING a CTE's column are now accepted.
  • The stand-in frees each result once it's read, so memory stays flat over a long run. On an account, startup checks every table the grader's role must see.

None of this moved a calibration number. The description has the details.

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 24, 2026 19:35
@yaoyu-33
yaoyu-33 requested a review from agronskiy November 24, 2026 20:10
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 24, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label Nov 24, 2026
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 25, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Nov 26, 2026
@ffrujeri

ffrujeri commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@agronskiy could you finish the review of the Snowflake stand-in and its execution verifier? The author pushed fixes from two reviews on 2026-11-22, and CI is green at 8a48e65. If you cannot take it this week, could you say so here, so the review can move to someone else?

@github-actions github-actions Bot removed the community-request Issue reported or requested by someone from the community label Dec 1, 2026
NVIDIA-NeMo#6711 (BIRD versions and the schema-only prompt) and this branch both added a
section after the dialect notes in benchmarks/birdbench/README.md. Both are
kept: the Snowflake section first (it belongs to the dialect notes), then
main's Versions and Schema-only prompt sections. No other conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label Dec 1, 2026
…l_context test, annotations

Review-readiness changes for the Snowflake dialect, no grading change:

- The lines this PR adds say "verifier", the repo's word, not "grader"
  (26 lines in the READMEs, the loader, setup and tests, including the
  loader's --grant-to help text; the fake _FakeGraderConnection is now
  _FakeVerifierConnection).
- bird_sql's README lists the licenses of what the Snowflake dialect adds to
  this server's lock: fakesnow (Apache-2.0 by its repository LICENSE; its
  package classifier says MIT), snowflake-connector-python (Apache-2.0), duckdb,
  and the connector's other new dependencies (MIT or Apache-2.0).
- A copy of the Snowflake sql_context test is in
  tests/unit_tests/benchmarks/test_birdbench_snowflake_context.py, since CI
  doesn't run benchmarks/*/tests. Its BM25 retriever is stubbed out (CI's core
  environment has no bm25s or nltk); its assertions cover the schema rendering
  only. The original stays, with the real retriever; each points at the other.
- birdbench's README says the Snowflake exclusion list and its counts are for
  dev_20240627 only: snowflake_gold_check.py has no --version.
- Annotations in the files this PR adds, and on the lines it adds to
  eval_utils.py and app.py, use built-in generics, X | None and A | B (ruff
  UP006, UP007, UP035, UP045). Lines that already exist on main are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@yaoyu-33 yaoyu-33 added the Nemotron Work related to NVIDIA Nemotron label Dec 1, 2026
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Push history, moved out of the description to keep it short. Newest first.

Since 8a48e65df93bae1b589fbe32498e5e93b73e7acc (this push)

  • A merge of main, which now carries feat(birdbench): add BIRD's 2025-11-06 dev and both Mini-Dev releases as dated versions, and a schema-only prompt #6711 (BIRD versions and the schema-only prompt). One conflict, in the birdbench README, where both PRs added a section; both are kept.
  • The lines this PR adds say "verifier", the repo's word, instead of "grader", including the loader's --grant-to help text.
  • The bird_sql README lists the licenses of everything the Snowflake dialect adds to the server's lock.
  • A copy of the Snowflake sql_context test is in tests/unit_tests/benchmarks/, where CI runs it, with its BM25 retriever stubbed out (CI's core environment has no bm25s). The original stays in benchmarks/birdbench/tests with the real retriever.
  • The birdbench README says the Snowflake exclusion list is for the default version only (snowflake_gold_check.py has no --version).
  • Annotations in the files this PR adds, and on the lines it adds elsewhere, use built-in generics and X | None.

08823c96d4778bc05931f0b430044daeb10ff26a to 8a48e65df93bae1b589fbe32498e5e93b73e7acc

  • A merge of main with fix(birdbench): sanitize Spark table names #6534 (sanitized Spark table names); one docstring conflict, both sentences kept.
  • A transport error without a SQLSTATE is masked as a verifier error. The stand-in frees each query's cached result once read.
  • The static check accepts a comment after the last semicolon and JOIN ... USING a CTE's column (neither occurs in the 4,614 saved queries); identifiers resolve per table and per alias; a bare function in FROM is refused and VALUES columns are accepted. Each checked on the account.
  • A query's timeout counts from its start, not from waiting for a thread or a login; setup that takes over two minutes is masked as an engine failure. On an account, the client waits 10 s past the server's statement timeout, and a timed-out query is interrupted until its thread stops. A query timed out while connecting no longer runs afterwards, and its semaphore slot is held until the worker stops.
  • A result over 5,000,000 rows scores as the query's failure; the account check names every table the role can't see.
  • Docs: what an account leaves to the read-only role (TABLE(...) functions such as QUERY_HISTORY()) and the per-query login.

5705851061543ffb73934c5e39a367e0fa9e13b6 to 08823c96d4778bc05931f0b430044daeb10ff26a (November 20)

  • A merge of main: the bird_sql lock conflicted after build(deps): upgrade all managed dependency locks #6528 and was re-locked from main's, keeping main's versions except the two our dependencies force down.
  • The static check refuses the aggregate FILTER (WHERE ...) clause and six DuckDB-only functions; 6 of the 14 Lightning answers that passed only on the stand-in used them.

5705851061543ffb73934c5e39a367e0fa9e13b6 (November 20)

  • Account connections turn off secondary roles.
  • The static check refuses SUM/AVG of a boolean and a DISTINCT ordered by an unselected column (17 translated golds Snowflake refuses had passed on the stand-in).
  • The calibration numbers in the READMEs; snowflake_gold_check.py --snowflake-connection grades on an account; snowflake_load_account.py, load_bird_snowflake_account and the startup check for unreadable databases.

@abelatnvidia

Copy link
Copy Markdown
Contributor Author

@anwithk, here's a licensing check for this PR, raised now so it doesn't hold up the merge later, as the driver question did on #6708. The Snowflake dialect adds these to bird_sql's lock only (not to nemo_gym), imported only for dialect: snowflake:

  • fakesnow 0.12.1. Its repository's LICENSE and its package License field are Apache-2.0, but its PyPI classifier says MIT.
  • snowflake-connector-python 4.8.1: Apache-2.0.
  • What they bring in: duckdb, asn1crypto, jmespath and pytz (MIT); boto3, botocore, pyopenssl, s3transfer and sortedcontainers (Apache-2.0).

None is GPL or LGPL. Unless you say otherwise, I'll treat fakesnow as Apache-2.0, per its LICENSE file. The list is also in the bird_sql README.

@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Merged current main to clear the conflict, and brought this PR's wording, tests and annotations in line with the repo's conventions; the push-history comment above lists the changes, and no grading logic changed. The licensing question is in its own comment to @anwithk.

@agronskiy this is the head to review. @ffrujeri could you /ok to test 4a542802354788ecb3eea967b5703c37b5990ecf?

dhruvnathawani
dhruvnathawani previously approved these changes Dec 3, 2026

@dhruvnathawani dhruvnathawani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minor suggestions

if isinstance(column.this, exp.Star):
continue
source = scope.sources.get(column.table) if column.table else None
if isinstance(source, exp.Table) and source.name in tables and column.name not in tables[source.name]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you account for renamed columns in table aliases? SELECT a.y FROM "t" AS a(y) is valid Snowflake SQL but currently gets scored as pred_sql_error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static check now handles renamed columns in FROM "t" AS a(y), both qualified (a.y) and unqualified (y). It rejects extra aliases and rejects the previous names when the list renames every column. With a partial list, the check keeps the previous names because the catalog lacks column order. DuckDB checks those cases at execution.

deadline = timeout_s + getattr(snowflake, "timeout_buffer_s", 0.0)
elapsed = time.monotonic() - started.result() if started.done() else 0.0
try:
return await asyncio.wait_for(asyncio.shield(worker), timeout=max(0.0, deadline - elapsed))

@dhruvnathawani dhruvnathawani Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you stop and drain the SQL worker on CancelledError before releasing the semaphore? Cancelling a request currently leaves its query running and allows concurrency to exceed the configured limit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cancellation now holds the semaphore slot until the Snowflake worker exits, including cancellation during connect, repeated cancellation during the drain, and shutdown. On a real Snowflake account, interrupt() is a no-op, so the slot stays held until the query returns or STATEMENT_TIMEOUT_IN_SECONDS stops it. The SQLite gold step and Spark executor still have their existing cancellation gap.

abelatnvidia and others added 7 commits December 2, 2026 21:54
…s query before releasing the slot

Review on NVIDIA-NeMo#6483:
- A table alias with a column list (SELECT a.y FROM "t" AS a(y)) renames the table's columns: the new names are
  accepted, and with every column renamed the old ones are refused, as Snowflake does. With fewer names than columns
  the old names stay accepted too, since the catalog doesn't keep column order.
- If the request is cancelled while its Snowflake query runs, the query is interrupted and its worker thread drained
  before the semaphore slot is released (also when cancelled again while draining), so no more queries run at once
  than the configured limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…ion drains even when the interrupt fails

Codex double-blind review of b584dfe:
- Unqualified columns are judged against the columns each table shows under its alias, so a new name that another
  table also has is accepted and a renamed-away name is refused.
- More alias names than the table has columns is refused (alias_columns), as Snowflake does; a table alias with a
  column list is no function call for the SQLite/DuckDB function scan.
- _stop_snowflake_worker keeps interrupting and waiting when an interrupt raises, and raises that error only after
  the worker thread has ended; the cancellation path waits for the stop without shielding its exception into the
  caller, so the slot is held until the thread ends.
- The cancellation test's fake query ends only when interrupted (no timing dependence), and covers a failed first
  interrupt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
… alias-name exemption

Codex double-blind review of 1b3ed04:
- The query runs on its own thread whose end is a plain future, not a to_thread task: cancelling every task (as
  asyncio.run does on shutdown) can no longer mark it done while the thread runs, and the cancellation drain calls
  the stop inline, restarting it if cancelled again, so the slot is held until the thread has ended.
- A later successful interrupt clears an earlier interrupt error.
- The token scan's alias exemption is dropped: exempting an alias name let a real call of that name through
  anywhere in the statement. An alias named like a refused function stays a (contrived) false positive.
- Tests: the second cancel provably lands mid-drain (the worker's connection close is gated), and a request
  cancelled while connecting holds its slot until the thread ends.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…query thread keeps the request's context

Codex double-blind review of 15d235c:
- SELECT y AS "x" FROM "t" AS a(y) WHERE "x" > 0 is accepted: select aliases count in the unqualified check even
  when a catalog column has the same name.
- The query thread runs in a copy of the request's context (as asyncio.to_thread did) and isn't a daemon (as the
  default executor's workers weren't), and the cancellation path retrieves a worker failure it doesn't pass on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…ead is explicitly not a daemon

Codex double-blind review of 8a8dc71: the select-alias allowance in the unqualified check was statement-wide, so an
alias in one UNION branch excused a column in another (SELECT "X" FROM "t" UNION ALL SELECT 0 AS "X"). It is now
the aliases of the column's own SELECT. daemon=False is set explicitly, since a thread otherwise inherits its
creator's flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
… stops keep the interrupt interval

Codex double-blind review of 3ab54da:
- SELECT "X" AS "X" FROM "t" is refused again: the own-SELECT alias allowance leaves out the alias whose
  definition holds the column.
- When repeated cancellation restarts the drain (an AnyIO cancel scope cancels every wait), interrupts stay one
  retry interval apart instead of running at event-loop speed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
… interval

Codex double-blind review of 0701aa4 (nothing blocking): after a restart, the next interrupt round now comes one
retry interval after the last one, not a full interval after the restart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Pushed 0372a0e6962864993936e1fc2f34d7b62f3b2fe9 with the alias and cancellation changes. All 142 Snowflake tests passed locally.

@dhruvnathawani could you re-review the new head? @ffrujeri could you run /ok to test 0372a0e6962864993936e1fc2f34d7b62f3b2fe9?

@ffrujeri

ffrujeri commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/ok to test 0372a0e

… coverage)

The core test test_birdbench_snowflake_context.py imports setup_bird_snowflake,
which imports setup_bird_spark, so both now count toward the combined core
coverage gate. The core environment has no duckdb, fakesnow,
snowflake-connector-python or pyspark, so most of both files went unmeasured
(206 statements missed; 94.87% against 95.00%). These tests replace those
packages with fakes in sys.modules and check the statements, parameters and
failure handling each setup path sends to its engine. Both files are fully
covered by them. Also removes setup_bird_snowflake._db_ids, which nothing
called.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

CI missed the combined core coverage gate (94.87% vs 95%). ccc9126e adds core tests for the Snowflake and Spark setup modules. All 36 passed locally.

@ffrujeri could you run /ok to test ccc9126e1cd1dcf1fdb3e2b690948fc73578ee9d? @dhruvnathawani could you re-review the new head?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer Nemotron Work related to NVIDIA Nemotron risk:high Autobot PR risk: high sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants