Skip to main content

Overview


Expressions are the core logical units of DQL. They describe how values are computed, compared, transformed and combined. Each query in DQL is built by composing expressions into nested structures.

Expressions follow a structured and typed format. Each expression defines a single value or operation and can appear inside other expressions to form complex logic.

This page provides a categorized overview of expression types in DQL. It introduces how expressions work and groups them by their purpose such as value references, control logic, containers, function calls and logical operators.


Example:​

This example selects the average revenue per region from the orders table. It combines projection, aggregation, aliasing, and grouping, which is all represented using nested expressions inside a $selectNode:

{
"$selectNode": {
"$select": {
"$columns": [
{ "$identifier": "region" },
{
"$as": "avg_revenue",
"$agg": {
"$fn": "avg",
"$operands": [ { "$identifier": "revenue" } ]
}
}
],
"$groupBy": [
{ "$identifier": "region" }
],
"$from": "orders"
}
}
}

Control & Structural​

Expressions that define top-level structure, aliasing, modifiers, and control flow.

"$selectNode": Object ( SetOperation )

"$case": Object ( Case )

"$as": <string>, <expression>

"$distinct": <boolean>, <expression>

"$modifier": Object ( Modifier )

"$derivedColumns": <boolean>

Value & Reference​

Primitive values, literals, and references to data. See Identifiers & Literals.

"$identifier": <string>

"$qualifier": [ <string>, <string> ]

"$scalar": <string> | <number> | <boolean> | <null>

"$literal": <string>

"$const": <string>

"$var": <string> | <number> | <boolean> | <null>

"$arg": <string>

"$null": <boolean>

"$unsafe": <string>

"$collate": Array ( <string> )

Containers & Composition​

Structures for grouping and composing expressions.

"$list": Array ( Expression )

"$tuple": Array ( Expression )

"$map": Array ( [2] Array ( Expression ) )

"$values": Array ( Expression )

"$columns": Array ( Expression )

"$unpacked": Array ( Expression )

"$star": Object ( Star )

Casting & Typing​

Operations for casting, coercion, and typing metadata. See Casting.

"$cast": <string>

"$shortCast": Array ( <string> )

Function Expressions​

Functions applied to one or more operands, including aggregates and windows. See Function Expressions.

"$unary": Object ( Unary )

"$binary": Object ( Binary )

"$variadic": Object ( Variadic )

"$agg": Object ( Aggregate )

"$window": Object ( Window )

Logic & Conditions​

Boolean logic, comparisons, pattern matching, and subquery checks. See Logical Expressions.

"$and": [ LogicalExpression, ... ]

"$or": [ LogicalExpression, ... ]

"$xor": [ LogicalExpression, ... ]

"$not": LogicalExpression

"$eq": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$neq": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$gt": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$gte": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$lt": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$lte": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$between": { "$left": [ <Expression> ], "$lower": [ <Expression> ], "$upper": [ <Expression> ] }

"$in": { "$left": [ <Expression> ], "$right": [ <Expression>, ... ] }

"$like": { "$left": [ <Expression> ], "$right": [ <Expression> ], "$escape": <string> }

"$similar": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$exists": { "$selectNode": Object ( SetOperation ) }

"$is": { "$left": [ <Expression> ], "$right": [ <Expression> ] }

"$distinctFrom": { "$left": [ <Expression> ], "$right": [ <Expression> ] }