Skip to content

MV TimeSliceRewriteEquivalent rewrites cause wrong result #75150

Description

@Hyper-FF

Steps to reproduce the behavior (Required)

  -- minimal repro: a time_slice() rollup MV over-selects the whole bucket for a `=` filter on raw dt

  CREATE TABLE t (dt DATETIME) DUPLICATE KEY(dt)
  DISTRIBUTED BY HASH(dt) BUCKETS 1 PROPERTIES("replication_num"="1");
  -- two rows in the SAME 5-minute bucket [00:00, 00:05)
  INSERT INTO t VALUES ('2023-06-01 00:00:00'), ('2023-06-01 00:01:00');

  CREATE MATERIALIZED VIEW mv REFRESH MANUAL AS
  SELECT time_slice(dt, INTERVAL 5 MINUTE) AS t, count(*) AS c
  FROM t GROUP BY time_slice(dt, INTERVAL 5 MINUTE);
  REFRESH MATERIALIZED VIEW mv WITH SYNC MODE;

  SELECT count(*) FROM t WHERE dt = '2023-06-01 00:00:00';
  -- enable_materialized_view_rewrite = false : 1   (correct — only the 00:00:00 row)
  -- enable_materialized_view_rewrite = true  : 2   (WRONG — both rows in the 00:00 bucket)

Expected behavior (Required)

Real behavior (Required)

StarRocks version (Required)

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions