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

Open
sgrif opened this Issue Oct 1, 2015 · 6 comments

Comments

Projects
None yet
5 participants
@sgrif
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 from Allow supporting multiple aggregate columns to Allow selecting multiple aggregate columns Oct 1, 2015

@sgrif

This comment has been minimized.

Member

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

This comment has been minimized.

Member

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

This comment has been minimized.

nikomatsakis commented Mar 14, 2016

@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

This comment has been minimized.

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

This comment has been minimized.

Pyriphlegethon commented Apr 9, 2016

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

mujx added a commit to mujx/ruma that referenced this issue Dec 27, 2016

Add endpoint to retrieve room's latest state events
Currently diesel doesn't support this type of query so raw SQL was used.

diesel-rs/diesel#3

mujx added a commit to mujx/ruma that referenced this issue Dec 27, 2016

Add endpoint to retrieve room's latest state events
Currently diesel doesn't support this type of query so raw SQL was used.

diesel-rs/diesel#3

mujx added a commit to mujx/ruma that referenced this issue Dec 27, 2016

Add endpoint to retrieve room's latest state events
Currently diesel doesn't support this type of query so raw SQL was used.

diesel-rs/diesel#3
@weiznich

This comment has been minimized.

Contributor

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment