Based on How to do multi selects in Ecto, using a subquery
may help?
Something like:
var = 0
query = from t0 in "table", where: t0<^var, select: t0
Repo.all(from q in subquery(query), select: fragment("postgress_function(?)", ^q))