Skip to content

feat(native): extract raw and expanded SQL tests with one native extractor - #1026

Merged
kvlonge merged 2 commits into
mainfrom
feat/native-sql-test-extractor
Oct 8, 2026
Merged

kvlonge merged 2 commits into
mainfrom
feat/native-sql-test-extractor

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

SQL tests were split into CTEs twice: by a Python extractor before macro expansion (with a Polyglot fallback) and a native one after, which deferred to Python whenever adapter rules differed. They disagreed often, and the native one panicked on __udf followed by a no-break space.

Changes

  • One native extractor handles both passes on every engine under the adapter's lexical rules. The Python extractor, its Polyglot fallback and the deferral are removed. Expanded-test cache bumped to v3.
  • CTE-name errors are checked once on the authored block, before declaration scoping and expansion, and point at the exact file:line:column. Discovery records each block's authored span, so locations survive dedent, tabs and cases.
  • Behaviour changes, all engines:
    • CTE names must be unquoted ASCII identifiers.
    • Keywords match ASCII case-insensitively only.
    • Helper and expected CTEs may not call __udf/__table_fn (now also in macro tests).
    • Each malformed reference call in them is its own located P012.
    • Expected projections need an alias unless they are a bare or qualified column. Implicit aliases (1 order_id) count, but a trailing keyword or operand does not (a IS NULL, CASE … END).
    • Parenthesised or WITH expected branches are rejected; t.* and DISTINCT * count as SELECT *.
    • Duplicate actual/expected CTEs report as duplicate CTE names.
    • The no-break-space panic is a normal error.
  • Testing docs and skill copy describe the rules.

Verification

  • Differential fuzz vs the previous passes (20,000 tests, 7 adapter syntaxes): every mismatch is attributed to an agreed class, 0 unexplained, no panics.
  • Rust rule and authored-span tests; offset-mapping tests; DuckDB E2E on python, native and native-preview (21 cases, including exact locations and repeated P012); failure-corpus cases.
  • cargo test/clippy/fmt (1.99.0), compiler differential 224/224 (preview) and 218/218 (shipped), e2e harness, make check-ci, make test.

@kvlonge
kvlonge force-pushed the feat/native-sql-test-extractor branch from d974360 to 637c9b3 Compare October 8, 2026 11:00
@kvlonge
kvlonge enabled auto-merge (squash) October 8, 2026 11:25
@kvlonge
kvlonge merged commit 82b33b0 into main Oct 8, 2026
39 checks passed
@kvlonge
kvlonge deleted the feat/native-sql-test-extractor branch October 8, 2026 11:58
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