-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Bug in MV when it reads from the source #77327
Copy link
Copy link
Closed
Labels
potential bugTo be reviewed by developers and confirmed/rejected.To be reviewed by developers and confirmed/rejected.
Description
Company or project name
Clickhouse
Describe what's wrong
CREATE MATERIALIZED VIEW dst_mv Engine=Memory as select *, (SELECT count() FROM src_table) AS cnt FROM src_table;
Inner select reads from the inserted data. It suppose to read from the table itself.
Does it reproduce on the most recent release?
Yes
How to reproduce
create table src_table Engine=Memory as system.numbers;
CREATE MATERIALIZED VIEW dst_mv Engine=Memory as select *, (SELECT count() FROM src_table) AS cnt FROM src_table;
insert into src_table select 1 from numbers(3);
insert into src_table select 2 from numbers(2);
insert into src_table select 3 from numbers(1);
select 'the rows count get inserted in src_table';
SELECT count() FROM src_table;
select 'the rows get inserted in dst_mv';
select * from dst_mv order by number;
produces
the rows count get inserted in src_table
6
the rows get inserted in dst_mv
1 3
1 3
1 3
2 2
2 2
3 1
Proff: https://fiddle.clickhouse.com/19a890a7-b89e-4c45-9125-4b71a2b7abcb
Expected behavior
The result should be:
the rows count get inserted in src_table
6
the rows get inserted in dst_mv
1 0
1 0
1 0
2 3
2 3
3 5
Error message and/or stacktrace
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
potential bugTo be reviewed by developers and confirmed/rejected.To be reviewed by developers and confirmed/rejected.