Skip to content

Bug: FULL OUTER JOIN on global-aggregate MVs (no GROUP BY) returns empty result #24790

@qccash

Description

@qccash

Describe the bug

A downstream materialized view using FULL OUTER JOIN can return an empty result when both join inputs are materialized views built from global aggregation (no GROUP BY).

This is unexpected because both sides produce one row and the join keys match.

Error message/log


To Reproduce

drop table if exists t;
create table t (
  id int primary key,
  key string,
  amount int
);

insert into t values
  (1, 'k', 100),
  (2, 'k', 200);

-- two global-agg MVs (no GROUP BY)
create materialized view t1_v as
select sum(amount) as amount, max(key) as key
from t
where id = 1;

create materialized view t2_v as
select sum(amount) as amount, max(key) as key
from t
where id = 2;

-- downstream FULL OUTER JOIN MV
create materialized view t_stat as
select
  coalesce(a.key, b.key) as key,
  coalesce(a.amount, 0) as amount_1,
  coalesce(b.amount, 0) as amount_2
from t1_v a
full outer join t2_v b
  on a.key = b.key;

select * from t_stat;

Expected behavior

Expected behavior

 key | amount_1 | amount_2
-----+----------+----------
 k   |      100 |      200

Actual behavior

 key | amount_1 | amount_2
-----+----------+----------
(0 rows)

How did you deploy RisingWave?

No response

The version of RisingWave

<=2.7.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugType: Bug. Only for issues.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions