Yeah, we should show the error on the `distinct` expressions. If you can make it work by iterating over the distincts, then please do that. Otherwise you can manually annotate the raised `Ecto.QueryError` with type, file and line from the first distinct expression. The file and line are stored in `Ecto.QueryExpr` https://github.com/elixir-lang/ecto/blob/master/lib/ecto/query.ex#L122.