Skip to content

Close parser gaps on 15 syntax forms and judge depth like the product - #93

Closed
kvlonge wants to merge 6 commits into
mainfrom
fix/syntax-gaps
Closed

kvlonge wants to merge 6 commits into
mainfrom
fix/syntax-gaps

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Draft. Queue position (D213): after #91. Based on main 4f52a5b so its coverage numbers are measured cleanly; it will be merged up to main (no rebase) once #89–#91 have landed. The auditor reviews the 15 forms after it lands, because #89–#91 change the parser tree first.

Parser (crates/sqlquack-syntax, on the D118 re-read list)

  • CAST(x AS PRECISION) / AS VARYING: a lone second type word is SQ0001 in faithful modes (Snowflake 1003). DOUBLE PRECISION, CHARACTER VARYING and unknown names such as FOOBAR (2040, a compile error) still parse.
  • TO_TIMESTAMP(), TRY_TO_TIMESTAMP() and the other expression-list conversion calls parse with no arguments in faithful modes, as Snowflake does (it fails them at compile). IDENTIFIER() stays refused. Convert refuses these calls.
  • CREATE EXPERIMENT <name> TYPE = <value> [ FROM SPECIFICATION <text> ] is a parsed CreateObject, not opaque text, so a missing FROM or SPECIFICATION is a parse error (1003). CREATE <name> TYPE … with no object kind is 1003.
  • Known disagreement (D213), kept refused like ==: SELECT !SPCS_CANCEL_JOB ( ) (receipt kffa979cc1d0a, errno 2139) and SELECT !SPCS_WAIT_FOR ( v1 , v1 ) (receipt kf2fa04c919eb, errno 904). Accepting them would need a method-call node with no instance; recorded in the parser tests.

Checker

  • Local verdicts use the product's own function-call depth guard (sqlquack-core MAX_FUNCTION_CALL_DEPTH = 256) instead of the syntax crate's default 64. The product already accepts these statements, so the checker should judge them the same way. Closes the 100-deep ABS and COALESCE cases.

Coverage data

  • not_submitted entries for SYSTEM$ENFORCE_PRIVATELINK_ACCESS_ONLY, SYSTEM$ENABLE_PREVIEW_ACCESS and SYSTEM$DISABLE_PREVIEW_ACCESS, held by A's capture guard under its account-state rule (exclusions upheld by the auditor, wip/syntax-omission-audit 325ea0f). They stay in the denominator as unverifiable_not_submitted.

Translation statements (D151 slice-1 blockers)

  • verify --translation-statements no longer aborts the whole file when SQLQuack's parser refuses one recorded statement. That statement is written like any other (outcome, codes), with its token spelling keys as constructs and a new optional unparsed field holding the parse failure; syntax-coverage results reads it. The three D151 cases that hit it (DATE_PART and EXTRACT with a quoted part before FROM, MINHASH with DISTINCT) are compile_error cases Snowflake rejects at parse (1003), so SQLQuack's SQ0001 agrees with Snowflake and no parser change is needed.
  • Function construct keys replace spaces with underscores, so GROUPING SETS is fn:GROUPING_SETS, which form links can name (construct keys never hold whitespace).

Evidence

  • Forms whose only remaining reason is unreviewed: 15 (double, string, to-timestamp, try-to-timestamp, abs, coalesce, both ai-function create-experiment forms, 7 create-secret forms). Obligations 68,169 → 68,221 (+52, 0 lost). syntax-coverage diff coverage/syntax/baseline.json exits 0: forms_lost 0, syntax_error_cases_accepted 0, receipts_contradicted 0.
  • Over 54,228 receipted statements: 19 mismatches fixed, 0 new; only the targeted cases change tree. All 4,243 translation-case statements parse identically.
  • fmt, clippy and fensu clean; syntax, core, semantics and coverage tests pass; sqlquack lib 85/85. The CLI suite fails here only on the 3 Python-replay test_convert tests (no .venv in this worktree); they must pass in the gate environment before landing.

… EXPERIMENT TYPE

From recorded receipts:
- PRECISION or VARYING alone as a type is a parse error in faithful modes
  (Snowflake 1003); DOUBLE PRECISION, CHARACTER VARYING and unknown type
  names (2040, a compile error) still parse.
- TO_TIMESTAMP ( ) and the other expression-list conversion calls parse with
  no arguments in faithful modes, as Snowflake does (a compile error there).
  IDENTIFIER ( ) stays refused.
- CREATE EXPERIMENT <name> TYPE = <value> [ FROM SPECIFICATION <text> ] is a
  parsed CreateObject instead of opaque text, so a missing FROM or
  SPECIFICATION is a parse error (1003).
- CREATE <name> TYPE ... with no object kind is a parse error (1003).
…uard

The coverage checker parsed with the syntax crate's default guard, which
stops at 64 nested function calls, while every product parse allows 256
(sqlquack-core MAX_FUNCTION_CALL_DEPTH). Two documented 100-deep cases
(ABS, COALESCE) that Snowflake and the product both accept were reported
as local parse failures. The checker now uses the product's limit.
Snowflake parses SELECT !SPCS_CANCEL_JOB ( ) (receipt kffa979cc1d0a, errno
2139) and SELECT !SPCS_WAIT_FOR ( v1 , v1 ) (receipt kf2fa04c919eb, errno
904) and fails them at compile. Like ==, SQLQuack keeps refusing them at
parse rather than add a model-attribute node with no instance.
The auditor upheld A's exclusions from the brq-execute-00 packet
(coverage/syntax/audits/receipt-exclusions-brq-execute-00.toml on
wip/syntax-omission-audit 325ea0f). Nine of the twelve held cases already
had not_submitted entries. These three did not:
SYSTEM$ENFORCE_PRIVATELINK_ACCESS_ONLY, SYSTEM$ENABLE_PREVIEW_ACCESS and
SYSTEM$DISABLE_PREVIEW_ACCESS. Their o001 obligations now report as
unverifiable_not_submitted instead of missing a receipt, and they stay in
the denominator.
The parser names GROUPING SETS as a call with a space, so the statements
file listed fn:GROUPING SETS, which form links cannot name: construct keys
never hold whitespace. Function construct keys now replace spaces with
underscores, giving fn:GROUPING_SETS.
verify --translation-statements stopped the whole file at the first recorded
statement SQLQuack's parser refused. Such a statement is now written like
any other, with its outcome and codes, its token spelling keys as its
constructs, and an optional unparsed field holding the parse failure.
syntax-coverage results reads the field. The three D151 cases that hit it
(DATE_PART and EXTRACT with a quoted part before FROM, MINHASH with
DISTINCT) are compile errors Snowflake rejects at parse, so SQLQuack's
refusal agrees with Snowflake.

kvlonge commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing: SQLQuack lands through local-gate trains, not PR merges (D94), so open PRs only add clutter (D628/D630). The branch is kept. Any work here that isn't on main yet is tracked by the train owner and lands through a train.

@kvlonge kvlonge closed this Nov 8, 2026
@kvlonge
kvlonge deleted the fix/syntax-gaps branch November 9, 2026 21:32
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