# `Macaw.Data.Ops`
[🔗](https://github.com/dcoai/macaw_data/blob/v0.5.3/lib/macaw/data/ops.ex#L1)

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})
    end

In 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}]

# `aggregate`

```elixir
@spec aggregate(Enumerable.t(), String.t()) :: term()
```

As `aggregate/3` with no options.

# `aggregate`

```elixir
@spec aggregate(Enumerable.t(), String.t(), map()) :: term()
```

The named aggregate of `values`, `nil`s dropped, with its `options`.

# `transform`

```elixir
@spec transform(Macaw.Data.Table.source() | Macaw.Data.Table.t(), String.t()) :: [
  map()
]
```

As `transform/3` with no options.

# `transform`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
