StarRocks / starrocks

The world's fastest open query engine for sub-second analytics both on and off the data lakehouse. With the flexibility to support nearly any scenario, StarRocks provides best-in-class performance for multi-dimensional analytics, real-time analytics, and ad-hoc queries. A Linux Foundation project.
https://starrocks.io
Apache License 2.0
8.9k stars 1.78k forks source link

The materialized view has four base tables, one of which is empty, resulting in the failure to rewrite the materialized view. #48888

Open guoxiaolongzte opened 3 months ago

guoxiaolongzte commented 3 months ago

create table a; create table b; create table c; create table d;

CREATE MATERIALIZED VIEW view1 DISTRIBUTED BY HASH(`) REFRESH ASYNC EVERY(INTERVAL 1 MINUTE) PROPERTIES ( "replicated_storage" = "true", "replication_num" = "1", "storage_medium" = "HDD" ) as select id from a join b join c join d;

There is data in tables a, b, and d, but no data in table c.

explain select id from a join b join c join d , the materialized view has not been rewritten.

code com/starrocks/sql/optimizer/Optimizer.java:498 //ruleRewriteIterative(tree, rootTaskContext, RuleSetType.PRUNE_EMPTY_OPERATOR) after annotation, it can be routed to the materialized view. why?

Steps to reproduce the behavior (Required)

Expected behavior (Required)

Real behavior (Required)

StarRocks version (Required)

LiShuMing commented 2 months ago

There is no benefit to rewrite empty table/plan, seems no bug here.

Can you try it again with some datas?