Converting a nested keyword list into a keyword map

Yeah, I also think that’s best solution.

I do not have repository to test this code, but it should look like:

alias Ecto.Query
require Query

Store
|> Query.from(as: :store)
|> Query.group_by([store: store], [store.state, store.city])
|> Query.select([store: store], %{
  a: store.state,
  b: store.city,
  c: fragment("array_agg(?)", store.name)
})