[Bug] 在明细模型上建立物化视图后,聚合查询结果不正确
Search before asking
- [X] I had searched in the issues and found no similar issues.
Version
2.0.2
What's Wrong?
按照官方文档,创建明细基表:
create table sales_records(record_id int, seller_id int, store_id int, sale_date date, sale_amt bigint) distributed by hash(record_id) properties("replication_num" = "1");
建立物化视图:
create materialized view store_amt as select store_id, sum(sale_amt) from sales_records group by store_id;
插入数据:
insert into sales_records values(1,1,1,"2020-02-02",1),(1,2,2,"2020-02-02",1);
注意:这里store_id 不同。
查询聚合数据:
SELECT store_id, sum(sale_amt) FROM sales_records GROUP BY store_id;
结果:
期望结果:
应该有两条结果,分别表示 store_id=1和store_id=2的汇聚结果。
explain确认走了物化视图:
EXPLAIN SELECT store_id, sum(sale_amt) FROM sales_records GROUP BY store_id;
另外:当我先建立明细表,然后插入多条明细数据,再建立物化视图后,查询结果是正确的,但当再次插入数据后,结果就不正确了。
What You Expected?
分组聚合结果正确
How to Reproduce?
按照问题里步骤操作
Anything Else?
No response
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
进一步测试发现,在insert into values跟一条数据的情况下,统计是正确的,但同时插入多条数据时,结果是错误的。
very thanks for your report,I fix it on #27297.
请问什么时候能发布啊,2.0.2版本太多问题了,迫切需要发布新版解决。 master编译报错,跑不通···
we will release 2.0.3 on next week.
@BiteTheDDDDt 物化视图仍然存在问题。
在2.0.3 使用聚合模型,然后建立物化视图后,查询走物化视图得结果和不走物化视图得结果不一致。 走物化视图:
不走物化视图:
Can you provide a reproduction method?
抱歉,这个可能是个乌龙,我们得BE节点没有正确升级。
测试2.0.3上正常,可以关闭。 给你带来麻烦十分抱歉。
不走物化视图: 