TECHNOLOGY

Symmetric SQLite EXCEPT can miss wrong row multiplicities

In this article
THE QUICK TAKE

Choose set or multiset correctness explicitly; duplicate-removing comparisons cannot establish equal row multiplicities.

The generated-data scenario

A synthetic SQL task generates a reference query and a candidate query. The grader uses EXCEPT in both directions and finds no difference, yet the candidate returns repeated rows that the intended task should count separately. The queries agree as sets but not as multisets. The acceptance question is whether the oracle preserves the result property the task specifies, rather than whether a convenient SQL difference operation returns an empty result.

The generation mechanism

SQLite documents that EXCEPT removes duplicate rows, while UNION ALL retains them. A bidirectional EXCEPT comparison therefore does not by itself measure multiplicity. Its aggregate documentation separately distinguishes counting rows from counting non-NULL values. These semantics matter when generated queries include joins, repeated transactions or nullable fields: an equality check can silently discard exactly the distinction that makes the candidate answer incorrect for the declared task.

Define the dataset contract

Define the output contract as an ordered sequence, set or multiset, and state how types and missing values are compared. Do not select the easiest comparator after seeing which generated solution passes. A task about distinct categories can legitimately use set semantics, while one about repeated events may require multiplicity. Preserve the schema and reference result alongside this choice so the student’s target does not inherit an accidental deduplication policy.

A step-by-step protocol

First build a harmless database with repeated result rows and an explicit nullable case. Compare known queries that agree on distinct values but differ in occurrence counts. Inspect the symmetric-EXCEPT outcome and a comparator that preserves the intended multiplicities. For count-based checks, distinguish row count from non-NULL field count. Reload the task through the actual grading adapter and verify its result representation, rather than assuming the in-memory reference and serialized result use the same equality rule.

Evidence required for acceptance

Acceptance evidence includes database identity, query versions, output semantics and intentionally wrong candidate outcomes. A negative fixture must reject the multiplicity error when the task requires it. Retain the separate order policy so an arbitrary execution order does not become a false failure for an unordered task. A passing comparison on one database remains finite evidence; generated fixtures should expose the specific duplicate-sensitive behavior before the example is labeled a verified solution.

Failure cases and limits

This review does not prove general SQL equivalence or prescribe a universal grading metric. Collation, type conversion and engine differences can add further comparison questions. It reports no new model accuracy. The bounded result is a correct oracle for a stated synthetic SQL task, preventing duplicate-removing set operators from being presented as proof that every occurrence, aggregate and answer count agrees with the intended specification.

Choose set or multiset correctness explicitly; duplicate-removing comparisons cannot establish equal row multiplicities. SQLite compound SELECT duplicate semantics; SQLite count rows versus non-NULL values.

The proposed investigation of sqlite except synthetic sql multiplicity oracle is a proposed dataset-contract review; no production dataset was generated or evaluated. Related reading: Spider: evaluate SQL on unseen database schemas; Frictionless Table Schema: validate logical values before feature building.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles