Materialized view SUM returns 0 instead of NULL after deleting the last non-NULL value in a group
Author: iany0Created Sep 27, 2026Updated Sep 27, 2026
Labelstype/bug
Describe the bug
After deleting a group's last non-NULL value, the group remains with one NULL row. The maintained materialized view returns SUM = 0, while the direct query and a newly recreated materialized view return NULL. The group still contains one row with a NULL value. Recreating the materialized view on the unchanged data correctly returns NULL.
Error message/log
Reading `m` returns `(1, 0)`, the direct defining query returns `(1, NULL)`.To Reproduce
CREATE TABLE t0 (g INT, v INT);
INSERT INTO t0 VALUES (1, NULL);
INSERT INTO t0 VALUES (1, 1);
FLUSH;
CREATE MATERIALIZED VIEW m AS
SELECT g, SUM(v) AS s FROM t0 GROUP BY g;
FLUSH;
DELETE FROM t0 WHERE v = 1;
FLUSH;
SELECT * FROM m;
SELECT g, SUM(v) AS s FROM t0 GROUP BY g;Expected behavior
Both SELECTs return (g = 1, s = NULL), the surviving group has no non-NULL SUM input.
How did you deploy RisingWave?
official Linux x86_64 release binary
The version of RisingWave
PostgreSQL 13.14.0-RisingWave-3.1.0 (45baf6460ea942e4ff57a5aa057d5b8db7f3b563)
Additional context
No response
Source: risingwavelabs/risingwave