Story 14.1 — Epic 14 R1 Analytical SQL
Accept and translate the ANSI standard ORDER BY col [ASC|DESC] [NULLS FIRST | NULLS LAST] clause. Elasticsearch sort already supports null-handling via the missing parameter (_first | _last); this exposes that control at the SQL surface.
Behavior
NULLS FIRST → "missing": "_first"
NULLS LAST → "missing": "_last"
- When omitted, defaults follow the Elasticsearch convention (
ASC → nulls last, DESC → nulls first).
- Rejected on GROUP BY / aggregation
ORDER BY (ES terms aggregations have no missing parameter) rather than silently dropped.
Scope
- SQL AST:
NullOrdering trait + NullsFirst / NullsLast + FieldSort.nullOrdering.
- Parser: optional
NULLS FIRST / NULLS LAST after ASC/DESC (case-insensitive).
- Bridge: apply
.missing(_first|_last) on the FieldSort builder (covers ES7/8/9; ES6 hand-mirrored).
- Tests: parser round-trip, bridge JSON emission, integration specs for ES 6/7/8/9.
- Docs:
documentation/sql/dql_statements.md + web dql.mdx.
Known limitation
ES6 Jest scroll / search_after does not propagate NULLS FIRST / NULLS LAST reliably across batches.
BMAD Story 14.1 (Epic 14 — Analytical SQL).
Story 14.1 — Epic 14 R1 Analytical SQL
Accept and translate the ANSI standard
ORDER BY col [ASC|DESC] [NULLS FIRST | NULLS LAST]clause. Elasticsearchsortalready supports null-handling via themissingparameter (_first|_last); this exposes that control at the SQL surface.Behavior
NULLS FIRST→"missing": "_first"NULLS LAST→"missing": "_last"ASC→ nulls last,DESC→ nulls first).ORDER BY(ES terms aggregations have nomissingparameter) rather than silently dropped.Scope
NullOrderingtrait +NullsFirst/NullsLast+FieldSort.nullOrdering.NULLS FIRST/NULLS LASTafter ASC/DESC (case-insensitive)..missing(_first|_last)on theFieldSortbuilder (covers ES7/8/9; ES6 hand-mirrored).documentation/sql/dql_statements.md+ webdql.mdx.Known limitation
ES6 Jest scroll / search_after does not propagate
NULLS FIRST/NULLS LASTreliably across batches.BMAD Story 14.1 (Epic 14 — Analytical SQL).