Обсуждение: Bug in aggregates in windowing context
Folks, Elein Mustain mentioned this, and I came up with a short repro. The SQL standard does not distinguish between what's available to aggregates normally and in the windowing context. However... SELECT count(DISTINCT i) FROM (VALUES (1),(2),(3),(1)) AS s(i);count ------- 3 (1 row) SELECT count(DISTINCT i) OVER () FROM (VALUES (1),(2),(3),(1)) AS s(i); ERROR: DISTINCT is not implemented for window functions LINE 1: SELECT count(DISTINCT i) OVER () FROM (VALUES (1),(2),(3),(1... ^ I see the error set up in src/backend/parser/parse_func.c, but no real reasoning why. Anyhow, I think it's a bug and needs back-patching. Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
David Fetter <david@fetter.org> writes: > SELECT count(DISTINCT i) OVER () FROM (VALUES (1),(2),(3),(1)) AS s(i); > ERROR: DISTINCT is not implemented for window functions Which part of that message isn't clear to you? > Anyhow, I think it's a bug and needs back-patching. "Not implemented" is not a bug. Nice try though. regards, tom lane
On Wed, Sep 09, 2009 at 06:35:05PM -0400, Tom Lane wrote: > David Fetter <david@fetter.org> writes: > > SELECT count(DISTINCT i) OVER () FROM (VALUES (1),(2),(3),(1)) AS s(i); > > ERROR: DISTINCT is not implemented for window functions > > Which part of that message isn't clear to you? A bug that's documented in the source code is still a bug. Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
David Fetter <david@fetter.org> writes: > A bug that's documented in the source code is still a bug. Sorry, but we are not going to define every unimplemented feature in SQL:2008 as being a back-patchable bug fix candidate. As for the "it's not documented" argument, I direct you to section 4.2.8, which is pretty explicit about what the allowed syntax is. (And btw, I'm equally uninterested in the other omissions in that compared to SQL:2008. We did what we could for 8.4.) regards, tom lane
On Wed, Sep 9, 2009 at 6:24 PM, David Fetter<david@fetter.org> wrote: > Anyhow, I think it's a bug and needs back-patching. I suspect if it were as easy as removing the error test it would have been done already. Perhaps you'd care to submit a patch? ...Robert
On Wed, Sep 09, 2009 at 08:45:06PM -0400, Robert Haas wrote: > On Wed, Sep 9, 2009 at 6:24 PM, David Fetter<david@fetter.org> wrote: > > Anyhow, I think it's a bug and needs back-patching. > > I suspect if it were as easy as removing the error test it would > have been done already. Perhaps you'd care to submit a patch? Working on that at the moment :) Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate