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

Group by alias with distinct count doesn't work #3423

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Group by alias with distinct count doesn't work #3423

monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working normal SQL

Comments

@monetdb-team
Copy link

Date: 2014-01-20 20:51:03 +0100
From: Klaudiusz <>
To: SQL devs <>
Version: 11.17.9 (Jan2014)
CC: @njnes

Last updated: 2014-02-20 15:02:26 +0100

Comment 19474

Date: 2014-01-20 20:51:03 +0100
From: Klaudiusz <>

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36
Build Identifier:

Using alias in "group by" clause with count(distinct x) causes that query doesn't work.
Probably introduced by
http://dev.monetdb.org/hg/MonetDB/rev/78eca92f6d68

Reproducible: Always

Steps to Reproduce:

DROP table a;
CREATE table a (k int,b int);
INSERT into a values (1,2);
INSERT into a values (2,2);
INSERT into a values (3,3);
INSERT into a values (4,65);
INSERT into a values (5,21);

SELECT k as c,count(distinct b) from a group by c;

Actual Results:

nothing happens

Expected Results:

+------+------+
| c | L1 |
+======+======+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
+------+------+
5 tuples (1.538ms)

MonetDB 5 server v11.17.1 "Jan2014" (64-bit, 64-bit oids)
Copyright (c) 1993-July 2008 CWI
Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
Visit http://www.monetdb.org/ for further information
Found 252.2GiB available memory, 32 available cpu cores
Libraries:
libpcre: 7.8 2008-09-05 (compiled with 7.8)
openssl: OpenSSL 1.0.1e 11 Feb 2013 (compiled with OpenSSL 1.0.1e-fips 11 Feb 2013)
libxml2: 2.7.6 (compiled with 2.7.6)
Compiled by: @ (x86_64-redhat-linux-gnu)
Compilation: gcc -O3 -fomit-frame-pointer -pipe -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wp,-D_FORTIFY_SOURCE=2
Linking : /usr/bin/ld -m elf_x86_64

Comment 19482

Date: 2014-01-22 12:13:17 +0100
From: @njnes

fixed a bug in the relational optimizer. Rewriting of some special case of distinct with count incorrectly used the expressions of the lower relation. Now it correctly uses the alias names.

Comment 19486

Date: 2014-01-22 13:08:59 +0100
From: @sjoerdmullender

Since this bug was reported against the RC, we need the NEXTRELEASE resolution (assuming the fix will appear in the correct branch).

Comment 19488

Date: 2014-01-22 13:17:00 +0100
From: MonetDB Mercurial Repository <>

Changeset 9d8906d9166d made by Niels Nes niels@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=9d8906d9166d

Changeset description:

fixed bug #3423, improved the group by + distinct rewrite
also added a test for this bug

Comment 19594

Date: 2014-02-20 15:02:26 +0100
From: @sjoerdmullender

Jan2014 has been released.

@monetdb-team monetdb-team added bug Something isn't working normal SQL labels Nov 30, 2020
@sjoerdmullender sjoerdmullender added this to the Ancient Release milestone Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working normal SQL
Projects
None yet
Development

No branches or pull requests

2 participants