Plan ops

The relational steps of a plan, the form agents emit and the hint language compiles to.

The steps of a plan (hint.plan/1): each node names an op, its input nodes and its parameters. A table verb runs one op over the tables it names.

read

A table the host resolves by name.

Inputs 0
Rows keeps the rows
Parameter Type Required Notes
input string yes The name the host gives the table.

filter

The rows where the predicate is true; null and false drop the row.

Inputs 1
Rows keeps some rows
Parameter Type Required Notes
predicate expr yes A Bool expression over the input's columns.

project

The listed columns, computed row by row.

Inputs 1
Rows keeps the rows
Parameter Type Required Notes
columns array of named no The output columns, each a name and an expression.

join

Two inputs combined; expressions see the left input's columns, then the right's.

Inputs 2
Rows changes the rows
Parameter Type Required Notes
asof asof no For kind asof: the left and right values to match by nearness, the strategy (backward, forward, nearest) and an optional literal tolerance; keys are the equal by keys.
keys array of join_key no Equi-join keys: a left and a right expression; none for a cross join.
kind "inner" | "left" | "right" | "full" | "semi" | "anti" | "mark" | "single" | "cross" | "asof" yes Which rows are kept and which side may be null.
nulls_equal boolean no Whether null keys match each other.
residual expr no An extra Bool predicate over the left then the right columns; not for asof.

aggregate

One row per group, with its measures; one row in all without groups.

Inputs 1
Rows changes the rows
Parameter Type Required Notes
group_by array of named no The grouping keys; null is one key.
grouping_sets array of array of integer no Grouping sets as lists of group_by indices; a key outside a set is null in its rows, and [] is the grand total. Rows come by set, then key order.
measures array of measure no Aggregate calls, each with an optional filter and, for ordered ones, an order.
set_index string no With grouping_sets: the name of an Int64 column, after the keys, holding each row's set index.

sort

A stable sort.

Inputs 1
Rows keeps the rows
Parameter Type Required Notes
keys array of sort_key no The keys, most significant first; nulls last unless asked.

window

Window columns appended to each row.

Inputs 1
Rows keeps the rows
Parameter Type Required Notes
columns array of named no The appended columns: window functions or aggregates.
frame frame no The rows an aggregate sees: unit rows or range (peers as one), start and end bounds. Default: the partition start to the current row's last peer with an order_by, the whole partition without. Ranking and lag/lead ignore it.
order_by array of sort_key no The order within a partition; ordered functions need it.
partition_by array of expr no The partitions.

set

A set operation by column position with matching types.

Inputs 2
Rows changes the rows
Parameter Type Required Notes
all boolean no Keep duplicates (multiset semantics).
op "union" | "intersect" | "except" yes Which operation.

fetch

count rows from offset, in input order.

Inputs 1
Rows keeps some rows
Parameter Type Required Notes
count integer no at least 0. Rows kept; all the rest when absent.
offset integer no at least 0. Rows skipped.

topk

The k first rows by the keys.

Inputs 1
Rows keeps some rows
Parameter Type Required Notes
k integer yes at least 0. How many rows.
keys array of sort_key no The order.
with_ties boolean no Keep the rows tied with the k-th.

unnest

A list column's items, one row each.

Inputs 1
Rows changes the rows
Parameter Type Required Notes
column integer yes at least 0. The list column's ordinal.
keep_empty boolean no Keep a row whose list is empty or null, with a null item.
offset_column string no The name of an Int64 column of item positions (from 1), placed after the items.

distinct

One row per key.

Inputs 1
Rows keeps some rows
Parameter Type Required Notes
keep "first" | "last" no Which row of a key stays.
keys array of expr no The key; every column when empty.
order_by array of sort_key no The order keep follows; input order when empty.

sample

A seeded sample: each row with a probability, or exactly n rows.

Inputs 1
Rows keeps some rows
Parameter Type Required Notes
count integer no at least 0. Exactly this many rows, or all when fewer (reservoir); give this or fraction.
fraction number no at least 0, at most 1. The probability of each row (Bernoulli); give this or count.
seed integer yes at least 0. The seed; nothing is random by default.