Planning (commons lang-sql 0010-aide FR-006, FR-007): a query over one table as a plan of scan, filter, sort, project and limit, written as text by explain, and split, which divides a plan between a backend that can do some of it and the process that does the rest, so that the residual run on what the backend gives is what the whole plan gives.
Spec: 0010-aide FR-006, FR-007
Source: commons/lang-sql/src/aide/plan/mod.ts
4 of 8 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
Plantypeno test imports ittype Plan =
| { readonly kind: "scan"; readonly table: string; readonly alias: string; /** the backend has done the wo… (592 characters)
type Plan =
| { readonly kind: "scan"; readonly table: string; readonly alias: string; /** the backend has done the work of the plan below it */ readonly pushed: boolean }
| { readonly kind: "filter"; readonly input: Plan; readonly predicate: Expr }
| { readonly kind: "sort"; readonly input: Plan; readonly order: readonly OrderItem[] }
| { readonly kind: "project"; readonly input: Plan; readonly items: readonly SelectItem[]; readonly distinct: boolean }
| { readonly kind: "limit"; readonly input: Plan; readonly limit: number | undefined; readonly offset: number | undefined };
A logical plan of a query over one table.
PlanErrorinterfaceno test imports itinterface PlanError
A construct the planner does not plan.
| Member | Type | What it is |
|---|
start | number | |
end | number | |
message | string | |
function plan(select: Select, bound: Bound): Result<Plan, readonly PlanError[]>
The plan of a query over one table; an error value for a construct it does not plan.
Imported by 8 tests of the run (8 passed, 0 failed): the library's results
function explain(p: Plan): string
A plan as text, one operator on a line, the input of an operator below it and indented.
Imported by 8 tests of the run (8 passed, 0 failed): the library's results
interface Capabilities
What a backend can do.
| Member | Type | What it is |
|---|
canEval | (expr: Expr) => boolean | Whether the backend evaluates this expression exactly as SQL does. |
sort | boolean | Whether it orders by expressions it can evaluate. |
limit | boolean | Whether it limits the rows it gives. |
Imported by 8 tests of the run (8 passed, 0 failed): the library's results
Pushedinterfaceno test imports itinterface Pushed
What goes to the backend.
| Member | Type | What it is |
|---|
table | string | |
alias | string | |
predicate | Expr | undefined | |
sort | readonly OrderItem[] | undefined | |
limit | { readonly limit: number | undefined; readonly offset: number | undefined; } | undefined | |
Splitinterfaceno test imports itinterface Split
A plan divided between a backend and the process.
| Member | Type | What it is |
|---|
pushed | Pushed | |
residual | Plan | What the process runs on the rows of the pushed part. |
function split(p: Plan, caps: Capabilities): Split
Divides a plan: each conjunct the backend can evaluate is pushed, the sort where the backend can, the limit where nothing stands between.
Imported by 8 tests of the run (8 passed, 0 failed): the library's results