yield — emit values from expressions
[yield] <expr> [, <expr>...]
The yield
operator produces output values by evaluating one or more
expressions on each input value and sending each result to the output
in left-to-right order. Each <expr>
may be any valid
expression.
The yield
keyword is optional since it is an
implied operator.
Hello, world
# spq
yield "hello, world"
# input
null
# expected output
"hello, world"
Yield evaluates each expression for every input value
# spq
yield 1,2
# input
null
null
null
# expected output
1
2
1
2
1
2
Yield typically operates on its input
# spq
yield this*2+1
# input
1
2
3
# expected output
3
5
7
Yield is often used to transform records
# spq
yield [a,b],[b,a] | collect(this)
# input
{a:1,b:2}
{a:3,b:4}
# expected output
[[1,2],[2,1],[3,4],[4,3]]