Using variables inside AQL (a.k.a. LET bindings)

Precomputed values can be transported through a transformation pipeline within the values themselves, but that can be unergonomic (would usually be done by wrapping in an object that has additional properties).

FROM 'my-tag'
SELECT { orig: _, id: _.["Inconvenient"].some[3] }
SELECT {
    start: _.orig.start[_.id]
    end: _.orig.end[_.id]
}

The same can be achieved with better ergonomics by binding a value to a name and then having that name available for the rest of the query.

FROM 'my-tag'
LET id := _.["Inconvenient"].some[3]
SELECT {
    start: _.start[id]
    end: _.end[id]
}

Specification

A new transformation stage is added with the syntax

LET <ident> := <expr>

The <ident> is a string starting with a lowercase letter and continuing with lowercase letters, digits, or underscores. Within the <expr> the current input is bound to _, like for SELECT. If the expression yields a value, then the current input is passed on to the next stage and the variable binding is added to the evaluation context, so that the name can be referred to in all following stages — it is likely that the introduction of AGGREGATE will restrict this since the variable loses its meaning after the aggregation step.