Skip to content

Commit d1dc640

Browse files
committed
chore: remove the Polyglot equivalence check
Real Snowflake results, the referee and the recorded receipts, are now the only bar for the Snowflake parser, so the forked code can diverge from Polyglot as it is fixed. - tools/sqlquack-polyglot-check, its expected differences, the polyglot-sql workspace dependency and its lockfile entries, and the polyglot-duckshop target are gone. CallMode::FaithfulWithSpans, which only the check used, goes with them. - polyglot-guard goes too: with no polyglot dependency left, nothing needs guarding. - syntax-coverage corpus-verdicts, part of check-ci, records whether SQLQuack parses each statement of the corpora under corpora/polyglot-check and fails on any change; make corpus-verdicts-baseline records a reviewed change. It keeps the two checks the removed crate ran that never involved Polyglot: the lossless tokens rebuild each statement byte for byte, and its located parse equals its faithful parse once spans are removed. - docs/syntax.md and docs/architecture.md no longer hold the parser to Polyglot's behaviour. The convert-layout change's exact-check failure was Polyglot's alone. SQLQuack parses the laid-out and compact DuckDB output of every recorded case to the same tree, apart from the raw text CREATE MACRO keeps. Polyglot refuses lambda parameters named by keywords and nested parenthesised UNION ALL operands, which DuckDB runs.
1 parent 11de3d7 commit d1dc640

108 files changed

Lines changed: 7043 additions & 5227 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
with:
214214
workspaces: fuzz
215215
shared-key: fuzz
216-
- name: Seed the corpus with the exact check's statements
216+
- name: Seed the corpus with the corpora's statements
217217
run: python3 -m scripts.seed_fuzz_corpus --out fuzz/corpus/tolerant
218218
- name: Fuzz
219219
working-directory: fuzz

‎Cargo.lock‎

Lines changed: 0 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ members = [
1212
"crates/sqlquack-compare",
1313
"crates/sqlquack-evidence",
1414
"crates/sqlquack",
15-
"tools/sqlquack-polyglot-check",
1615
"tools/sqlquack-coverage-check",
1716
"crates/sqlquack-syntax-postgres",
1817
"crates/sqlquack-lint",
@@ -45,17 +44,6 @@ anstream = "1.0"
4544
arrow = { version = "60", default-features = false, features = ["ipc"] }
4645
clap = { version = "4.5", features = ["derive"] }
4746
duckdb = "=1.20000.0"
48-
polyglot-sql = { git = "https://github.com/sqlstack-io/polyglot.git", rev = "7d5fe2ccce7b3cbd1413a2823560f8dfc63ecc2e", default-features = false, features = [
49-
"dialect-snowflake",
50-
"dialect-duckdb",
51-
"dialect-bigquery",
52-
"dialect-databricks",
53-
"dialect-postgresql",
54-
"dialect-sqlite",
55-
"generate",
56-
"semantic",
57-
"stacker",
58-
] }
5947
proc-macro2 = "1"
6048
quote = "1"
6149
rayon = "1"

‎Makefile‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PYTHON_TYPED := scripts tests/unit/scripts python/src $(PYTHON_API_TESTS)
3030
PYTHON_TESTS := tests/unit/scripts $(PYTHON_API_TESTS)
3131
endif
3232

33-
.PHONY: distribution-notices format rust-lint python-check fensu syntax-coverage depth-probe depth-probe-debug instruction-counts instruction-baseline gate-build polyglot-guard engine-free bundled-extensions dialect-builds generate-cases generated-cases generate-syntax-cases syntax-cases dialect-cases corpus-rerecord generate-referee-cases referee-cases referee-pending translation-files translation-results help pending check-syntax record-syntax check-convert record-convert sql-sizes sql-size-baseline sql-benchmark check-ci check-merge test test-rust test-python python-module python-api python-wheel verify-recorded verify-changed replay-scope test-crate check-pr-metadata evidence-clone evidence-refresh evidence-pin evidence-pin-check clutter-guard polyglot-duckshop census-duckshop fuzz-smoke gate gate-parallel census duckshop-compiled duckshop-measure
33+
.PHONY: distribution-notices format rust-lint python-check fensu syntax-coverage depth-probe depth-probe-debug instruction-counts instruction-baseline gate-build engine-free bundled-extensions dialect-builds generate-cases generated-cases generate-syntax-cases syntax-cases dialect-cases corpus-rerecord corpus-verdicts corpus-verdicts-baseline generate-referee-cases referee-cases referee-pending translation-files translation-results help pending check-syntax record-syntax check-convert record-convert sql-sizes sql-size-baseline sql-benchmark check-ci check-merge test test-rust test-python python-module python-api python-wheel verify-recorded verify-changed replay-scope test-crate check-pr-metadata evidence-clone evidence-refresh evidence-pin evidence-pin-check clutter-guard census-duckshop fuzz-smoke gate gate-parallel census duckshop-compiled duckshop-measure
3434

3535
format:
3636
cargo fmt --all
@@ -116,10 +116,6 @@ evidence-pin-check:
116116
clutter-guard:
117117
uv run python -m scripts.check_clutter_guard
118118

119-
# Fails when a crate other than the dev-only exact check reaches polyglot at runtime.
120-
polyglot-guard:
121-
uv run python -m scripts.check_polyglot_guard
122-
123119
# Fails when the conversion pipeline crate, which builds without DuckDB's engine, reaches it.
124120
engine-free:
125121
@tree="$$(cargo tree --locked -p sqlquack-convert -e normal --prefix none)" || exit 1; \
@@ -170,6 +166,15 @@ generate-cases:
170166
corpus-rerecord:
171167
SQLQUACK_RERECORD=1 cargo test --locked -p sqlquack --lib everyday_corpus
172168

169+
# Checks SQLQuack's parse verdict on every statement of the corpora under corpora/polyglot-check
170+
# against coverage/syntax/corpus-verdicts.json, and fails on any change.
171+
corpus-verdicts: gate-build
172+
$(GATE_DIR)/syntax-coverage corpus-verdicts
173+
174+
# Records the verdicts corpus-verdicts checks. Run it in the change that moves one, and commit it.
175+
corpus-verdicts-baseline: gate-build
176+
$(GATE_DIR)/syntax-coverage corpus-verdicts --update
177+
173178
# Fails when a generated case file differs from what its generator writes.
174179
generated-cases:
175180
uv run python -m scripts.generate_cases --check $(GENERATED_CASE_ARGS)
@@ -220,7 +225,7 @@ referee-pending:
220225
uv run python -m scripts.write_referee_pending $(REFEREE_ARGS)
221226

222227
# The static gate, the first step of `gate`, and the Python API's tests.
223-
check-ci: rust-lint python-check fensu syntax-coverage depth-probe instruction-counts evidence-pin-check clutter-guard polyglot-guard engine-free bundled-extensions dialect-builds generated-cases syntax-cases dialect-cases referee-cases translation-files python-api distribution-notices replay-scope ## The static gate CI runs.
228+
check-ci: rust-lint python-check fensu syntax-coverage depth-probe instruction-counts corpus-verdicts evidence-pin-check clutter-guard engine-free bundled-extensions dialect-builds generated-cases syntax-cases dialect-cases referee-cases translation-files python-api distribution-notices replay-scope ## The static gate CI runs.
224229

225230
# Each distribution ships the licence and third-party notices; its copies must match the root files.
226231
distribution-notices:
@@ -484,14 +489,6 @@ duckshop-compiled:
484489
(cd $(DUCKSHOP_DIR)/duckshop-10k && $(abspath $(DUCKSHOP_DIR)/venv/bin/sqb) compile); \
485490
echo "$(SQLBUILD_REF) $(SQLBUILD_VERSION)" > $(DUCKSHOP_DIR)/.ref
486491

487-
# The exact parser check over each compiled DuckShop project in DUCKSHOP_COMPILED.
488-
polyglot-duckshop:
489-
@for compiled in $(DUCKSHOP_COMPILED); do test -d "$$compiled" || \
490-
{ echo "polyglot-duckshop: $$compiled is missing; run make duckshop-compiled" >&2; exit 1; }; done
491-
for compiled in $(DUCKSHOP_COMPILED); do \
492-
cargo run --locked --release -p sqlquack-polyglot-check -- directory "$$compiled" --dialect snowflake || exit 1; \
493-
done
494-
495492
# Converting each compiled DuckShop project, with chained models and a diagnostic for each blocked
496493
# file, must finish within DUCKSHOP_CENSUS_SECONDS. DuckShop 10K takes about 25 s on a development
497494
# machine; 300 s is about twelve times that, room for slower CI runners, so only a pathological
@@ -537,7 +534,7 @@ duckshop-measure: duckshop-compiled
537534
--sqlquack "$$target/release/sqlquack" --library "$$library" \
538535
--work "$$out/work" --out "$$out/snowflake.json"
539536

540-
# Fuzzes each of FUZZ_TARGETS from the exact check's statements for FUZZ_SECONDS: tolerant parsing,
537+
# Fuzzes each of FUZZ_TARGETS from the corpora's statements for FUZZ_SECONDS: tolerant parsing,
541538
# and strict parsing through to rendered diagnostics.
542539
fuzz-smoke:
543540
uv run python -m scripts.seed_fuzz_corpus --out $(FUZZ_CORPUS)
@@ -546,8 +543,8 @@ fuzz-smoke:
546543
-max_total_time=$(FUZZ_SECONDS) -max_len=4096 -timeout=10 -rss_limit_mb=2048) || exit 1; \
547544
done
548545

549-
# Everything CI runs: the static gate, the tests, the recorded-case replay, the exact check and the
550-
# timed conversion on DuckShop, and the fuzz smoke.
546+
# Everything CI runs: the static gate, the tests, the recorded-case replay, the timed conversion on
547+
# DuckShop, and the fuzz smoke.
551548
# After the static gate, the independent targets run in parallel, each target's output kept
552549
# together; any failure fails the gate. The fuzz smoke and then the SQL timing benchmark run alone
553550
# afterwards, so each gets the machine to itself.
@@ -556,7 +553,7 @@ gate: check-ci $(if $(filter command line,$(origin DUCKSHOP_COMPILED)),,duckshop
556553
$(MAKE) fuzz-smoke
557554
$(MAKE) sql-benchmark
558555

559-
gate-parallel: test-rust test-python verify-recorded polyglot-duckshop census-duckshop
556+
gate-parallel: test-rust test-python verify-recorded census-duckshop
560557

561558
# Example: make census CENSUS_ARGS="path/to/sql --json"
562559
census:

‎THIRD_PARTY_NOTICES‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ answer from Snowflake itself. sqlglot's expected DuckDB output is kept in the `s
1111
field as reference side data only: it is never asserted, does not count toward verification and
1212
is not part of the case hash.
1313

14-
The exact-check corpus corpora/polyglot-check/sqlglot.json holds the SQL of sqlglot's test
14+
The corpus corpora/polyglot-check/sqlglot.json holds the SQL of sqlglot's test
1515
fixtures at v30.14.0 (tests/fixtures/identity.sql, tests/test_parser.py and tests/dialects/),
1616
as extracted by polyglot's fixture tooling. polyglot, below, is itself inspired by sqlglot and
1717
ships sqlglot's licence. corpora/polyglot-check/sqlglot_postgres.json holds the SQL of
@@ -60,7 +60,7 @@ polyglot
6060
SQLQuack's tokenizer, parser and syntax tree are a modified fork of polyglot
6161
(https://github.com/tobilg/polyglot), as forked at https://github.com/sqlstack-io/polyglot.
6262
The derived code is in crates/sqlquack-syntax-snowflake, which now holds most of it,
63-
crates/sqlquack-syntax and crates/sqlquack-derive. The exact-check corpus
63+
crates/sqlquack-syntax and crates/sqlquack-derive. The corpus
6464
corpora/polyglot-check/polyglot_tests.json holds the SQL inputs of polyglot's tests.
6565
DuckDB's widening of a signed integer mixed with an unsigned one, unsigned_coercion in
6666
crates/sqlquack-semantics/src/duckdb/profile/_helpers/duck_types.rs, is ported from polyglot's

‎corpora/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ Inputs of checks that never ship. Their outcomes are not recorded here.
2222

2323
| Directory | Read by |
2424
|---|---|
25-
| `polyglot-check/` | `tools/sqlquack-polyglot-check`, which proves that `sqlquack-syntax` parses exactly as polyglot does, and the fuzz corpus seed (`scripts/fuzz_corpus`). `expected_differences.toml` lists the reviewed differences. The `*.NOTICE` files and `THIRD_PARTY_NOTICES` give the sources' licences. |
25+
| `polyglot-check/` | `syntax-coverage corpus-verdicts` (`make corpus-verdicts`), against SQLQuack's verdicts recorded in `coverage/syntax/corpus-verdicts.json`, and the fuzz corpus seed (`scripts/fuzz_corpus`). The `*.NOTICE` files and `THIRD_PARTY_NOTICES` give the sources' licences. |
2626
| `duckdb-core/` | The DuckDB parser's corpus tests in `crates/sqlquack-syntax-duckdb`; see its README. |
2727
| `databricks-core/` | The acceptance corpus for the Databricks parser, each statement tagged with the catalogue forms it uses; no test reads it yet. See its README. |

0 commit comments

Comments
 (0)