You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Strange behavior with 'where' condition after join. Some rows are discarded by mistake.
How to reproduce
Which ClickHouse server version to use
Latest version in Arcadia.
CREATE TABLE statements for all tables involved
createtablet0 (a Int64) engine = MergeTree() primary key a;
createtablet1 (a Int64) engine = MergeTree() primary key a;
Sample data for all these tables
insert into t0 values (1), (2);
insert into t1 values (1), (3);
Queries to run that lead to unexpected result
select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a) where type ='first';
select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a) where type in ('both', 'first', 'second');
Expected behavior
Result should contain 1 row in first query and 3 in second one.
Additional context
First two queries and the last one return correct results. Others do not. The queries differ only in 'where' condition.
di.man.yp-c.yandex.net :) select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a)
SELECT multiIf((a !=0) AND (t1.a!=0), 'both', (a !=0) AND (t1.a=0), 'first', (a =0) AND (t1.a!=0), 'second', 'error') AS type
FROM
(
SELECTt0.a,
t1.aFROM t0
FULL OUTER JOIN t1 USING (a)
)
Query id: 52e62625-d357-4fa4-babe-805332ab1dfd
┌─type──┐
│ both │
│ first │
└───────┘
┌─type───┐
│ second │
└────────┘
3 rows inset. Elapsed: 0.019 sec.
di.man.yp-c.yandex.net :) select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a) where type ='both'SELECT multiIf((a !=0) AND (t1.a!=0), 'both', (a !=0) AND (t1.a=0), 'first', (a =0) AND (t1.a!=0), 'second', 'error') AS type
FROM
(
SELECTt0.a,
t1.aFROM t0
FULL OUTER JOIN t1 USING (a)
)
WHERE type ='both'
Query id: 4ac91465-c66b-4aed-89cd-c6fbea58ff57
┌─type─┐
│ both │
└──────┘
1 rows inset. Elapsed: 0.028 sec.
di.man.yp-c.yandex.net :) select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a) where type ='first'SELECT multiIf((a !=0) AND (t1.a!=0), 'both', (a !=0) AND (t1.a=0), 'first', (a =0) AND (t1.a!=0), 'second', 'error') AS type
FROM
(
SELECTt0.a,
t1.aFROM t0
FULL OUTER JOIN t1 USING (a)
)
WHERE type ='first'
Query id: 5e90a617-d996-4fde-ace2-9a43e5c96906
Ok.
0 rows inset. Elapsed: 0.028 sec.
di.man.yp-c.yandex.net :) select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a) where type ='second'SELECT multiIf((a !=0) AND (t1.a!=0), 'both', (a !=0) AND (t1.a=0), 'first', (a =0) AND (t1.a!=0), 'second', 'error') AS type
FROM
(
SELECTt0.a,
t1.aFROM t0
FULL OUTER JOIN t1 USING (a)
)
WHERE type ='second'
Query id: a673bf99-0cfe-4782-912f-3132b150fd83
Ok.
0 rows inset. Elapsed: 0.027 sec.
di.man.yp-c.yandex.net :) select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a) where type in ('both', 'first', 'second')
SELECT multiIf((a !=0) AND (t1.a!=0), 'both', (a !=0) AND (t1.a=0), 'first', (a =0) AND (t1.a!=0), 'second', 'error') AS type
FROM
(
SELECTt0.a,
t1.aFROM t0
FULL OUTER JOIN t1 USING (a)
)
WHERE type IN ('both', 'first', 'second')
Query id: 8cc4b758-6b0d-41b3-8dc9-3932c46c00ce
┌─type──┐
│ both │
│ first │
└───────┘
2 rows inset. Elapsed: 0.028 sec.
di.man.yp-c.yandex.net :) select multiIf(a !=0andt1.a!=0, 'both', a !=0andt1.a=0, 'first', a =0andt1.a!=0, 'second', 'error') as type from (selectt0.a, t1.afrom t0 full join t1 using a) where type not in ('both', 'first')
SELECT multiIf((a !=0) AND (t1.a!=0), 'both', (a !=0) AND (t1.a=0), 'first', (a =0) AND (t1.a!=0), 'second', 'error') AS type
FROM
(
SELECTt0.a,
t1.aFROM t0
FULL OUTER JOIN t1 USING (a)
)
WHERE type NOT IN ('both', 'first')
Query id: e8f174d1-f2e4-424b-9ad0-2fa233ceb0b0
┌─type───┐
│ second │
└────────┘
1 rows inset. Elapsed: 0.034 sec.
The text was updated successfully, but these errors were encountered:
Describe the bug
Strange behavior with 'where' condition after join. Some rows are discarded by mistake.
How to reproduce
Which ClickHouse server version to use
Latest version in Arcadia.
CREATE TABLE
statements for all tables involvedExpected behavior
Result should contain 1 row in first query and 3 in second one.
Additional context
First two queries and the last one return correct results. Others do not. The queries differ only in 'where' condition.
The text was updated successfully, but these errors were encountered: