probcomp/bayeslite

expand subquery column lists first before macro expansion

Closed this issue · 1 comments

Currently we expand subquery column lists -- SELECT t.(SELECT ...) -- at the same time we format the SQL output. The ad hoc macro expansion for SIMULATE <compound expression> FROM MODELS OF p that I added last week happens before that, but for SIMULATE t.(<subquery>) FROM MODELS OF p to work, we need the macro expander to know the list of variables produced by first. So the easiest way to accomplish that will be to do things in three stages:

  1. Expand subquery column lists.
  2. Expand compound expression SIMULATE into SELECT of primitive expression SIMULATE.
  3. Generate SQL.