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

Bug in subselect (count function) #6686

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

Bug in subselect (count function) #6686

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

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2019-02-22 12:33:33 +0100
From: Manuel <>
To: SQL devs <>
Version: 11.29.7 (Mar2018-SP1)
CC: @njnes

Last updated: 2019-11-28 10:00:04 +0100

Comment 26903

Date: 2019-02-22 12:33:33 +0100
From: Manuel <>

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Build Identifier:

With a table created as follows:

CREATE TABLE "sys"."unitTestDontDelete" (
"A" VARCHAR(255),
"B" BIGINT,
"C" DOUBLE,
"D" TIMESTAMP
);
INSERT INTO "sys"."unitTestDontDelete" VALUES (NULL, NULL, NULL, NULL);
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 0, 0.5, '2013-06-10 11:10:10.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 1, 1.5, '2013-06-11 12:11:11.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 2, 2.5, '2013-06-12 13:12:12.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 3, 3.5, '2013-06-13 14:13:13.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 4, 4.5, '2013-06-14 15:14:14.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 5, 5.5, '2013-06-15 16:15:15.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 6, 6.5, '2013-06-16 17:16:16.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat2', 7, 7.5, '2013-06-17 18:17:17.000000');
INSERT INTO "sys"."unitTestDontDelete" VALUES ('Cat1', 8, 8.5, '2013-06-18 19:18:18.000000');

The query:

with "c3_t" as
(
select
"c1_t"."A",
"c1_t"."B",
"c1_t"."C",
"c1_t"."D"
from
"unitTestDontDelete" as "c1_t"
)
select
"c3_t"."C",
(
select
count(*)
from
"c3_t" as "c4_t"
where
"c4_t"."C" >= coalesce("c3_t"."C", 0.0) + 1
)
as "c2_f1"
from
"c3_t"

returns

C c2_f1

8
0.5 8
1.5 7
2.5 6
3.5 5
4.5 4
5.5 3
6.5 2
7.5 1
8.5 1

where I was expecting

C c2_f1

8
0.5 8
1.5 7
2.5 6
3.5 5
4.5 4
5.5 3
6.5 2
7.5 1
8.5 0

as there are no values for the "C" column >= 9.5

Reproducible: Always

Steps to Reproduce:

1.Import table
2. execute query as per details
3.

Actual Results:

C c2_f1

8
0.5 8
1.5 7
2.5 6
3.5 5
4.5 4
5.5 3
6.5 2
7.5 1
8.5 1

Expected Results:

C c2_f1

8
0.5 8
1.5 7
2.5 6
3.5 5
4.5 4
5.5 3
6.5 2
7.5 1
8.5 0

Comment 26905

Date: 2019-02-26 15:06:19 +0100
From: MonetDB Mercurial Repository <>

Changeset 095b4ca1f4fb made by Pedro Ferreira pedro.ferreira@monetdbsolutions.com in the MonetDB repo, refers to this bug.

For complete details, see https//devmonetdborg/hg/MonetDB?cmd=changeset;node=095b4ca1f4fb

Changeset description:

Added test for Bug #6686.

Comment 26982

Date: 2019-05-01 12:57:55 +0200
From: @njnes

fixed in default, where the subquery implementation is renewed

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

Successfully merging a pull request may close this issue.

None yet
1 participant