Generally I’d start by looking at the databases capabilities. Ecto cannot invent functionality the db doesn’t support.
Generally you can only join tablelike structures in sql, where the lines are considered rows. The easiest way to represent them in sql is VALUES
lists, but those are not supported by ecto at the moment (at least not with dynamic content).
Then there are various db specific functions to turn various shapes of data into rows. For postgres there’s for example unnest
(which I’ve used here) or my more recent favorite jsonb_to_recordset
: Postgres VALUES in query - #2 by LostKobrakai