What a derived source's stored function calls to reach the registered operations (spec/04 §6): an aggregate of values, or a transform over rows, by name, with the options a design's node would carry.
fn %{hosts: rows} ->
p95 = rows |> Enum.map(& &1.cpu) |> Macaw.Data.Ops.aggregate("quantile", %{p: 0.95})
rows
|> Macaw.Data.Ops.transform("filter", %{field: "cpu", test: :gte, value: p95})
|> Macaw.Data.Ops.transform("sort", %{field: "cpu", order: :descending})
endIn a stored function the name is a literal string the checker holds to the engine's
registry, and the call is compiled against that registry (__run__/5), so it runs
exactly what was checked. Called from a host's own code, the functions use
macaw_data's own package. A fault in the options raises ArgumentError with
Macaw.Data.Operations.format_error/1's words.
iex> Macaw.Data.Ops.aggregate([3, nil, 1, 2], "median")
2
iex> Macaw.Data.Ops.transform([%{v: 2}, %{v: 1}], "sort", %{field: :v})
[%{v: 1}, %{v: 2}]
Summary
Functions
As aggregate/3 with no options.
The named aggregate of values, nils dropped, with its options.
As transform/3 with no options.
The named transform run over rows with options, its answer as rows.
Functions
@spec aggregate(Enumerable.t(), String.t()) :: term()
As aggregate/3 with no options.
@spec aggregate(Enumerable.t(), String.t(), map()) :: term()
The named aggregate of values, nils dropped, with its options.
@spec transform(Macaw.Data.Table.source() | Macaw.Data.Table.t(), String.t()) :: [ map() ]
As transform/3 with no options.
@spec transform(Macaw.Data.Table.source() | Macaw.Data.Table.t(), String.t(), map()) :: [map()]
The named transform run over rows with options, its answer as rows.