Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMULATE can't be used in a SELECT to generate multiple output rows from a single input row #17

Open
riastradh-probcomp opened this issue May 22, 2015 · 1 comment

Comments

@riastradh-probcomp
Copy link
Contributor

Someone might want to draw from a kind of fibre product -- for each model satisfying a certain predicate, simulate a bunch of answers to obtain rows of the form

(<modelno>, <simulated col0>, <simulated col1>, <simulated col2>, ...)

It is tempting to try to write something like

SELECT m.modelno, (SIMULATE col0, col1, col2 FROM t USING MODEL m.modelno LIMIT 10)
    FROM MODELS OF t AS m
    WHERE (ESTIMATE MUTUAL INFORMATION OF col8 WITH col1 IN t USING MODEL m.modelno) > 0.8

but SQL has no concept of generating multiple output rows from a single input row. In that context, only the first column of the first row of the SIMULATE will be relevant, because it is a scalar context.

@riastradh-probcomp riastradh-probcomp changed the title SIMULATE can't refer to enclosing scope SIMULATE can't be used in a SELECT to generate multiple output rows from a single input row May 22, 2015
@riastradh-probcomp riastradh-probcomp self-assigned this May 28, 2015
@riastradh-probcomp
Copy link
Contributor Author

One danger of any attempt to do this is that the query language may become Turing-complete.

Probably a better approach would be to do something like:

SIMULATE m.modelno, col0, col1, col2
    FROM GENERATOR t_cc, MODELS OF t AS m
    USING MODEL m.modelno
    WHERE (ESTIMATE MUTUAL INFORMATION OF col8 WITH col1 IN t USING MODEL m.modelno) > 0.8

But this level of detail will probably require writing our own query planner and perhaps whole SQL execution engine in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant