Semantics overview
The rules every compiler follows, one page for each topic.
Normative per AR-1 (the maintainers' private TRD, §7): this document, not any single compiler, is where these behaviors are decided (SEM-1..SEM-7 from the TRD, SEM-8 added in #2455). A backend compiler that disagrees with a rule below has a bug, not an alternative opinion. Every rule here is the target of conformance fixtures (spec/fixtures/, TRD T-1) authored in a later work item (#1630) — this document states the rule and gives illustrative examples; it does not itself constitute the enforceable test suite.
Each section follows the same shape: the rule, why it exists (the naive alternative it rules out — see TRD §1's problem statement for the catalogue of ways this translation is usually done badly), one worked example per backend family showing the same logical outcome reached through different backend-native mechanisms, an explicit "must NOT" list, and cross-links to the IR shapes in ir.schema.json that the rule constrains.
All SQL/Mongo/OpenSearch examples in the SEM-1..SEM-7 sections below are illustrative snippets to convey intent, not the literal compiler output for any one dialect. The literal rendering — identifier quoting, parenthesisation, which operator carries a negation, how a set is parameterized — is pinned separately in three addenda at the end of this document, all of which are normative and are byte-for-byte what the spec/fixtures/ artifacts contain: "Addendum — canonical SQL rendering" (SQL-0..SQL-8) for the Postgres reference arm and its four sibling dialects, "Addendum — canonical MongoDB rendering" (MDB-1..MDB-12) for the mongo.artifact.json arm, and "Addendum — canonical OpenSearch/Elasticsearch rendering" (OSE-0..OSE-14) for the search.artifact.json arm. A Mongo or OpenSearch snippet below is illustrative in exactly the way a SQL one is; where the two disagree — SEM-1's implicit {name: "Smith"} against MDB-1's explicit $eq, or its bare {"term": {"name.keyword": …}} shorthand against OSE-1's — the addendum is what a compiler follows.
- Case sensitivity: Every comparison and ordering of text ignores case by default. Case sensitivity is a setting of the field, not of the operator or of the place where the comparison appears. A filter on a field therefore always agrees with a sort on the same field.
- Null handling: A text field is blank when it is null or empty, and any other field is blank only when it is null. Not blank is exactly the opposite of blank. On an engine that stores an empty string as null, such as Oracle, the check reduces to null alone.
- Null ordering: Each sort key carries an explicit position for nulls, first or last, independent of the sort direction. The compiler follows it literally, with the engine's own syntax where there is one and an equivalent form where there is not. The AG Grid adapter supplies a default, because the grid itself does not send one.
- Dates and time zones: A calendar date without a time is kept apart from a moment in time with a zone. The adapter turns the grid's zone-less strings into typed values using the field's declared type and the zone of the request, never the zone of the server. No compiler guesses a zone.
- Type coercion: The grid sends numbers and dates as text. The adapter converts each value once, using the type the schema declares for the field, and no compiler converts it again. A value that cannot be converted is a request error in Strict mode.
- Deterministic paging: Every grid names a unique stable key. The compiler adds it as the last sort key, after the keys the user chose, so that rows with equal values always come back in the same order. The added key gets a null position like any other sort key.
- Substring matching on OpenSearch: On OpenSearch and Elasticsearch, contains and not contains look for the text inside the value, exactly as a SQL substring match does. There is no tokenising, stemming or relevance scoring. A field can opt in to full-text matching explicitly if a host wants that instead.
- Empty set membership: A set filter with an empty list of values is valid. In matches no row and not in matches every row, including rows whose field is null. The empty list combines with and, or and not by ordinary logic.
- Aggregations: A count counts the rows where the named field has a value, never all rows. The rules also say what the result column is called and how grouping keys are matched. An aggregation over a group with no values has a defined answer, and a known difference in the placement of null groups on OpenSearch is recorded.
- Grouping and drill-down: Each request opens one level of a grouped grid and carries the path of groups above it. Group values are matched exactly, and the output columns are named at every level. A drill-down is compiled like any other filter, combined with the user's own filter.
- Export: An export is a request of its own kind. It drops the grouping state and names its output columns, which an ordinary row query does not. The export scope chooses the page mode and nothing else in the compiler changes; streaming and the CSV file itself are described elsewhere.
- SQL rendering: The same request must produce the same statement shape every time. Identifiers are always quoted, parentheses follow the structure of the filter, and negative operators use the negated operator. The page also lists where an engine differs, such as Postgres array parameters, collations and Oracle's empty-string rule.
- MongoDB rendering: A comparison is always a field document with an explicit operator, and the composites map to the matching MongoDB operators. Null inclusion, blank checks, ranges, collation and the escaping of patterns each have one fixed form. The pinned floor is MongoDB 4.2.
- OpenSearch and Elasticsearch rendering: Each construct has one fixed form: the kind of term query follows the field's type, null inclusion and blank checks have fixed shapes, and every sort spells out its order and missing-value rule. Grouping uses a composite aggregation and distinct values use a terms aggregation. One compiler serves both engines, and they differ only in how a point in time is handled.
- Execution equality: Comparing the text a compiler writes cannot see a collation that is ignored or a null that sorts the wrong way. Fixtures can therefore carry a seeded dataset and the rows a real engine must return, and the results are compared column by column and row by row. A known and accepted difference between engines is written down in the fixture.
- Cross-engine parity: One generated request, run over one seeded dataset on several engines, must return the same rows. The check covers combinations nobody wrote down by hand, and it keeps a register of the constructs it leaves out because engines are known to differ. A difference the check finds becomes a fixture.
- Query time limit: A host can set a maximum query time. The MongoDB and Search compilers then put it into the query they produce, so the database cuts a slow query instead of the application, and the adapters report one distinct time-out error. Without the setting nothing changes, exports never carry it, and a request can never set it.
- Default page size: A request that sends no row window now gets a default page (100 rows, a host setting) instead of the whole table. Every row is still available: an export of everything streams page by page, and a request can carry an explicit flag that the host has switched on. Without the host's switch the flag is refused, never silently capped.
- Count mode: A host often needs the total number of matching rows next to the page. Count mode compiles exactly that question: the same filter as the page, but no sort and no row window, so the database does not order rows it only counts. A grouped level counts its groups, and a window above the page limit does not make a count fail; the page query and every existing result stay as they are.