@terascope/data-mate / teal-frame/order-safety
teal-frame/order-safety
Functions
assertOrderSafe()
assertOrderSafe(
operation,ordered):void
Defined in: data-mate/src/teal-frame/order-safety.ts:14
Throws if an operation would silently discard the frame's ordering. Used by TealFrame's
join, distinct and aggregating select.
SQL does not guarantee that a subquery's ORDER BY survives the outer query. In DuckDB a
projection, WHERE, LIMIT or OFFSET keeps the order, but a hash join or hash aggregate
reorders rows. This only shows once the data is large enough to run in parallel (small
inputs come out ordered), so it is easy to miss in tests. Sort the result instead.
A global aggregate written directly into select's expressions with no groupBy
({ total: 'sum(x)' }) is not detected, because the expressions are raw SQL. It returns
one row, so the ordering does not matter.
Parameters
| Parameter | Type |
|---|---|
operation | string |
ordered | boolean |
Returns
void