Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,23 @@ def deps do
]
end
```

## Aggregate Strategies

`AshSql.Implementation` defaults aggregate planning to `:lateral`. SQL data
layers can override `aggregate_strategy/1` with `:grouped` when they need the
SQLite-style grouped aggregate implementation.

The grouped strategy uses adapter-provided list aggregation. Implementations
that select `:grouped` must implement `grouped_list_aggregate/2` and return a
list expression over the `:ash_sql_grouped_aggregate_window` window. The
grouped strategy assumes SQLite-compatible SQL: list defaults are JSON-encoded,
so list values must use a JSON list representation, and offset-only query
aggregates use `LIMIT -1`. AshSQLite uses SQLite's JSON list representation
for this callback.

The aggregate facade normalizes resource aggregates and SQL aliases before
dispatch. Both strategies preserve the source binding and attachment path, so
aggregates referenced through joined relationships attach to the related row.
Alias reuse is scoped to that path and follows the existing filter/sort identity
rules. Public aggregate names, including strings, are retained in results.
Loading