test(lower): SQL conformance over the DQC synthetic-packet-trace corpus - #56
Merged
Merged
Conversation
Adds the SQL counterpart of the awesome-prometheus-alerts corpus: the 70 evaluation queries from the DQC synthetic-network-trace fidelity benchmark (`metrics.py` `eval_metrics`) — 29 packet level, 21 flow stateless, 20 flow stateful — over `packets(srcip, dstip, srcport, dstport, proto, time, pkt_len)`. Tests only, no production code. The snapshot lives in `crates/lower/tests/data/synthetic_packet_trace_queries.sql`; the suite is `crates/lower/tests/synthetic_packet_trace.rs`. Corpus-wide invariant (`corpus_lowering_is_total_and_fully_supported`): - Totality — every query lowers to Ok or a clean LoweringError, never panics. - Full coverage — the DataFusion SQL front end lowers ALL 70 (CTEs, LAG window functions, multi-argument COUNT(DISTINCT …), STDDEV_POP, HAVING, CASE). A ratchet trips if coverage regresses below full. Plus shape tests pinning the canonical L3 for representative queries: COUNT(*) -> Count, COUNT(DISTINCT …) (incl. the multi-column 5-tuple form) -> Cardinality, 5-tuple GROUP BY -> five positional keys, SUM -> Sum, LAG(...) OVER (...) inter-arrival -> WindowFunc, STDDEV_POP -> population StdDev. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What & why
Adds the SQL counterpart of the awesome-prometheus-alerts corpus (#32): the 70 evaluation queries from the DQC synthetic-network-trace fidelity benchmark (
metrics.pyeval_metrics) — 29 packet level, 21 flow level stateless, 20 flow level stateful — as a real-world SQL conformance corpus.Each benchmark query is run on a real trace and a synthetic trace and the two result sets are compared to score fidelity; here we only lower them (parse → L2 → L3). The corpus pins the SQL front end against regressions the same way the PromQL alert corpus does.
Tests only — no production code changes. Snapshot:
crates/lower/tests/data/synthetic_packet_trace_queries.sql; suite:crates/lower/tests/synthetic_packet_trace.rs. Schema:packets(srcip, dstip, srcport, dstport, proto, time, pkt_len); flow / 5-tuple =(srcip, dstip, srcport, dstport, proto).Headline finding
The SQL front end lowers all 70/70 queries —
lowered: 70, rejected: 0, unparseable: 0. It handles every DQC construct end to end: CTEs (WITH), analytic window functions (LAG(time) OVER (PARTITION BY … ORDER BY time)), multi-argumentCOUNT(DISTINCT a, b, …),STDDEV_POP,HAVING, andCASE. Unlike the PromQL corpus (which is gated by the scalar-operand gap), the SQL side has no coverage gap on this benchmark.What it pins
Corpus-wide invariant (
corpus_lowering_is_total_and_fully_supported):Okor a cleanLoweringError, never panics.Shape tests (verbatim corpus queries) pin the canonical L3:
COUNT(*)→Count;COUNT(DISTINCT srcip)→CardinalityCOUNT(DISTINCT srcip, dstip, srcport, dstport, proto)(5-tuple) → oneCardinality, groupedGROUP BY→ five positional group keys +CountSUM(pkt_len)→SumLAG(time) OVER (…)inter-arrival gap → analyticWindowFuncSTDDEV_POP(gap)→ populationStdDevNotes
_topnvalue/_topnkey/_distributioncode variants are the same query scored with different distance metrics, so each is listed once (70 total).;-terminated statements;#/--comment lines. The parser strips comments before splitting on;, because the descriptions contain semicolons (e.g. "> 1 packet; zero duration").awesome_prometheus_alerts.rsstructure so the two corpora read the same way.🤖 Generated with Claude Code