Shape data
Tenzir comes with numerous transformation operators that do change the the shape of their input and produce a new output. Here is a visual overview of transformations that you can perform over a data frame:
We'll walk through examples for each depicted operator, using the
M57 dataset. All examples assume that you have imported
the M57 sample data into a node, as explained in the
quickstart. We therefore start every pipeline with
export
.
Filter events with where
Use where
to filter events in the
input with an expression:
Slice events with head
, tail
, and slice
Use the head
and
tail
operators to get the first or
last N records of the input.
Get the first event:
Get the last two events:
tail
is blockingThe tail
operator must wait for its entire input, whereas head N
terminates
immediately after the first N
records have arrived. Use head
for the
majority of use cases and tail
only when you have to.
The slice
operator generalizes head
and
tail
by allowing for more flexible slicing. For example, to return every
other event starting from the third:
Pick fields with select
and drop
Use the select
operator to
pick fields:
The drop
operator is the dual to select
and
removes the specified fields:
Sample schemas with taste
The taste
operator provides a sample of the
first N events of every unique schemas. For example, to get 3 unique samples:
Add and rename fields with set
assignment
Use the set
operator to add new fields to the
output.
Rename fields by combining set
with
drop
:
Similarly, you can rename and project at the same time with
select
:
Aggreate events with summarize
Use summarize
to group and aggregate
data.
A variety of aggregation functions make it possible to combine grouped data.
Reorder events with sort
Use sort
to arrange the output records
according to the order of a specific field.
Prepending the field with -
reverses the sort order.