DQL
DQL is a declarative query language for Go. You describe what you want as a document. DQL plans it, pushes down what the database can do, and finishes the rest in memory.
from:
dataset: spaces
where:
field: parent_id
op: "=="
value: "$parentId"
orderBy:
- field: sort_order
dir: ascThere is also a pipe mode: an ordered chain of operators applied to a stream of rows.
from:
dataset: events
pipe:
- op: filter
where: { field: status, op: "==", value: "open" }
- op: aggregate
groupBy: [assignee]
aggregate: [{ fn: count, as: total }]
- op: sortLimit
orderBy: [{ field: total, dir: desc }]
limit: 10Note
DQL is the Data Query Language. It describes queries over whatever data a host exposes, without assuming anything about what that data means.
Install01
go get github.com/xraph/dqlWhat is in the box02
| Package | Purpose |
dsl | The document types: QueryDSL, clauses, plan types |
parser | Parse and validate a document, classic or pipe mode |
planner | Decide what pushes down to SQL and what does not |
sqlgen | Emit SQL and its arguments from a plan |
processor | Finish in memory: computed columns, expression filters, sort |
pipe | The operator library: reshape, textual, quality, time, set ops |
exec | Run a plan against a database/sql-shaped connection |
expand | Turn id columns into display fields |
scope | Partition and tenant scoping |
Bring your own database03
exec.SQLQuerier is deliberately the shape database/sql already has, so anything
you already use satisfies it, including a pooled or instrumented wrapper.
type SQLQuerier interface {
Query(ctx context.Context, sql string, args ...any) (SQLRows, error)
}Status04
DQL was in production use as an embedded query engine before being published as a standalone project. The document format is stable.