-
Notifications
You must be signed in to change notification settings - Fork 5
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
at-querying a Query #20
Comments
would it be |
It would be the former. If |
Might that not be supported in the future? |
It will be supported, either as interpolation or something of a "prepared statements" API. |
Thanks for clarifying, so
will result in a "prepared statement", whereas qry2 = @query groupby(qry, C) might result in something different? |
Oh, I see what you were asking. No, there won't be interpolation or prepared statements for data sources. I see both interpolation and prepared statements as answers to the question, How do I refer to a value outside the "scope" of In the case of extending a Maybe a good way to summarize is: Interpolation/prepared statements lets you use different values in the same query, e.g. different values for |
That's a good enough distinction for me, thanks! So it should be x = 15
tbl1 = # some datasource
tbl2 = # some datasource
...
qry = @query :table1 |> innerjoin(:table2, ...) |> where(table2.col1 > $x)
collect(qry, table1 = tbl1, table2 = tbl2) rather than qry = @query :table1 |> innerjoin($tbl2, ...) |> where(table2.col1 > $x)
collect(qry, table1 = tbl1) ? |
How about the following proposal(s):
|
Actually, I think all mentions of dummy sources within qry = @query :table1 |> innerjoin(:table2, ...) |> where(:table2.col1 > $x)
collect(qry, table1 = tbl1, table2 = tbl2) I take the @collect tbl1 |> innjerjoin(tbl2, ...) |> where(tbl2.col1 > $x) whereas qry = @query :table1 |> innerjoin(:table2, ...) |> where(table2.col1 > $x)
collect(qry, table1 = tbl1, table2 = tbl2) would be equivalent to @collect tbl1 |> innerjoin(tbl2, ...) |> where(table2.col1 > $x) An alternative to having to repeatedly prepend qry = @query begin
tbl = :table2
table1 |> innerjoin(tbl, ...) |> where(tbl.col1 > $x)
end As for your proposals, here are my thoughts:
I can see why you want to unify the dummy source and prepared statements functionalities, but I do like having the syntax reflect the conceptual distinction between collecting a (fixed) query against different sources and collecting a prepared query with varying parameter values against a fixed source. One may want (I don't exactly know why, but I don't see why we shouldn't support it) to bind different values to a parametrized (prepared) qry = @query tbl |>
filter(A > c::Int) |>
select(B)
for _c in [1, 2, 3]
bind!(qry, c = _c)
do_something(qry)
end
end The second point concerning using Finally, there's an argument against using @collect filter(tbl, A == :a) -- you'd have to do qry = @query filter(tbl, A == :a)
collect(tbl, a = :a) # or, as I'd prefer, `bind` which I'm not really a fan of. Note that the dummy source functionality doesn't run into this problem because, within
Yes, and we will provide a definitive way to communicate to which source an un-prefixed
This tentatively sounds good, too -- I'll need to reason through this a bit more and see if it makes sense, since technically one is not interpolating into an Also, I'll add that if I had to choose |
Suppose a user produces a
Query
:It seems reasonable that a user ought to be able to extend this query by using it as the source of another query:
More specifically,
collect
ing againstqry2
should have the same result ascollect
ing againstI can see two ways to achieve this desired behavior:
Query
object itself, via a constructor:collect
I think I slightly prefer the first way.
The text was updated successfully, but these errors were encountered: