Operator
head — copy leading values of input sequence
Synopsis
head [ <const-expr> ]
limit [ <const-expr> ]
Description
The head operator copies the first N values from its input to its output and ends
the sequence thereafter. N is given by <const-expr>, a compile-time
constant expression that evaluates to a positive integer. If <const-expr>
is not provided, the value of N defaults to 1.
For compatibility with other pipe SQL dialects,
limit is an alias for the head operator.
Examples
Grab first two values of arbitrary sequence
# spq
head 2
# input
1
"foo"
[1,2,3]
# expected output
1
"foo"
Grab first two values of arbitrary sequence, using a different representation of two
# spq
const ONE = 1
limit ONE+1
# input
1
"foo"
[1,2,3]
# expected output
1
"foo"
Grab the first record of a record sequence
# spq
head
# input
{a:"hello"}
{a:"world"}
# expected output
{a:"hello"}