-
Notifications
You must be signed in to change notification settings - Fork 55
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
Allow query expressions to have group by
clause
#1134
Comments
The The syntax of the
The syntax
is short for
A group by clause is executed as follows
|
This has now been moved into a separate issue #1144. The semantics of aggregated variables needs some more detailed specification. When a variable
For example:
Here The expression
which is in turn equivalent to
If you want to get at the value of an aggregated variable as a list, you can do |
Regarding
after |
@suleka96 After the |
Ack. Just to confirm, if we have a code sample like the one shown below, the output will be
|
No. You can only reference aggregated variables in specific contexts. See #1144. The basic idea is that a reference to an aggregated variable |
As of now
Is it okay to reuse one of these representations for the |
#1137 (comment) raises the issue of whether we can have multiple One way to handle this would be to say that variables that were aggregated before the |
@jclark, please consider the following example. var input = [{name: "Saman", price1: 11, price2: 12},
{name: "Saman", price1: 11, price2: 14},
{name: "Kamal", price1: 12, price2: 12},
{name: "Kamal", price1: 12, price2: 14},
{name: "Saman", price1: 19, price2: 20}];
var y = from var {name, price1, price2} in input
group by price1
group by var p2 = [price2]
select [name]; // name is aggregated twice. In this example, Instead of that, we can do the following thing. var input = [{name: "Saman", price1: 11, price2: 12},
{name: "Saman", price1: 11, price2: 14},
{name: "Kamal", price1: 12, price2: 12},
{name: "Kamal", price1: 12, price2: 14},
{name: "Saman", price1: 19, price2: 20}];
var y = from var {name, price1, price2} in input
group by price1
let var n = [name]
group by var p2 = [price2]
select [n]; |
@KavinduZoysa That's a good question, which the spec needs to answer. I don't think your first example should be allowed. Your second example is fine. For now I think we should say that attempting to reference a doubly-aggregated variable is an error: we keep them in the frame, so that that cannot be shadowed. In the future, we could consider allowing access to them, so that something like this should work:
But that's something that can be left to later. |
This is part of #441.
The text was updated successfully, but these errors were encountered: