FROM (
(with
baz as (from baz101(500)),
bar as (from bar1(arg1, arg2))
from foo
)
UNION ALL
(with
baz as (from baz201(300)),
bar as (from bar2(arg3, arg4))
from foo
)
UNION ALL
...
)
SELECT *;
When you pass table arguments to a macro, don't pass them as a parameter to the macro, instead make a subquery and give it the name that `foo` expects.