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

Allow selecting multiple aggregate columns #3

Closed
sgrif opened this issue Oct 1, 2015 · 7 comments
Closed

Allow selecting multiple aggregate columns #3

sgrif opened this issue Oct 1, 2015 · 7 comments

Comments

@sgrif
Copy link
Member

sgrif commented Oct 1, 2015

I had hoped that this would just involve adding an Aggregate marker trait, and modifying the tuple impls to allow if all members are aggregate. This causes overlap since any type could implement both NonAggregate and Aggregate. I do not think there is a way to express this currently in the type system currently, without negative bounds (or maybe specialization)

@sgrif sgrif changed the title Allow supporting multiple aggregate columns Allow selecting multiple aggregate columns Oct 1, 2015
@sgrif sgrif mentioned this issue Feb 13, 2016
@sgrif
Copy link
Member Author

sgrif commented Mar 12, 2016

@aturon @nikomatsakis Was thinking about this recently, and thought you might be interested as it would have been helped by the lattice rule, but could be aided by other additions to the type system as well. Basically we have an impl that looks like this for every size tuple:

impl<T, U> Expression for (T, U) where
    T: Expression + NonAggregate,
    U: Expression + NonAggregate,
{
    // ...
}

What we need is to write something along the lines of:

impl<T, U> Expression for (T, U) where
    T: Expression + !NonAggregate,
    U: Expression + !NonAggregate,
{
    // ...
}

With the lattice rule we could have added an Aggregate trait, and then had an impl for T: Expression + Aggregate + NonAggregate with a body that would force it to fail to compile if it was ever used. Ultimately though, what we really need here is either negative reasoning, or mutual exclusion.

The main goal (in case there's another solution that I'm missing) is to make sure that we do not have an impl for T: Aggregate, U: NonAggregate.

@sgrif
Copy link
Member Author

sgrif commented Mar 12, 2016

Also I know you had asked me to keep you in the loop when I find some concrete examples to point you guys at. Is there a preferred form of communication besides just pinging you on issues like this?

@nikomatsakis
Copy link

@sgrif this seems good. The hard part I guess might be finding these examples later -- I'll try to keep a log. For what it's worth, this would probably be addressed by the semi-proposal for negative reasoning I advanced in this comment, which itself is just a variant on rust-lang/rfcs#1148.

@aturon
Copy link

aturon commented Mar 14, 2016

@sgrif Thanks for the heads up! In general issue comments like this are fine -- perhaps you could have a meta-issue with links to various examples as they come up, just so there's ultimately one place to track?

@Pyriphlegethon
Copy link

This problem could possibly be solved by using a PhantomData marker similar to these two examples: ebfull/pcap and hyperium/hyper.

@weiznich
Copy link
Member

weiznich commented Sep 2, 2017

When supporting multiple aggregate columns we should consider that there could be queries that mix aggregate and non-aggregate fields. See for example the following query:

SELECT a.id, count(b::id) FROM a LEFT JOIN b ON a.id = b.a_id GROUP BY a.id;

@weiznich
Copy link
Member

weiznich commented Jun 4, 2020

Closed by #2251

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

No branches or pull requests

5 participants