Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Wrong synchronized materialized view is selected #37207

Open
2 of 3 tasks
liutang123 opened this issue Jul 3, 2024 · 0 comments
Open
2 of 3 tasks

[Bug] Wrong synchronized materialized view is selected #37207

liutang123 opened this issue Jul 3, 2024 · 0 comments

Comments

@liutang123
Copy link
Contributor

liutang123 commented Jul 3, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Version

master

What's Wrong?

CREATE TABLE advertiser_view_record(
  time date not null,
  advertiser varchar(10),
  dt date not null,
  channel varchar(10),
  user_id int) 
DUPLICATE KEY(`time`, `advertiser`)
  PARTITION BY RANGE (dt)(FROM ("2024-07-02") TO ("2024-07-04") INTERVAL 1 DAY)
  -- AUTO PARTITION BY RANGE (date_trunc(`time`, 'day'))()
  distributed BY hash(time) 
  properties("replication_num" = "1");
CREATE materialized VIEW advertiser_uv AS
SELECT advertiser,
       channel,
       dt,
       bitmap_union(to_bitmap(user_id))
FROM advertiser_view_record
GROUP BY advertiser,
         channel,
         dt;
insert into advertiser_view_record values("2024-07-02",'a', "2024-07-02", 'a',1);
insert into advertiser_view_record values("2024-07-03",'b', "2024-07-03", 'b',1);
EXPLAIN
SELECT dt,advertiser,
       count(DISTINCT user_id)
FROM advertiser_view_record
GROUP BY dt,advertiser

The advertiser_uv can not be selected and the result is:

|   0:VOlapScanNode(421)                                                                              |
|      TABLE: test7.advertiser_view_record(advertiser_view_record), PREAGGREGATION: ON                |
|      partitions=2/2 (p_20240702,p_20240703)                                                         |
...
| MaterializedView                                                                                    |
| MaterializedViewRewriteSuccessAndChose:                                                             |
|                                                                                                     |
| MaterializedViewRewriteSuccessButNotChose:                                                          |
|   Names: internal#test_37207#advertiser_uv,                                                         |
| MaterializedViewRewriteFail:                                                                        |
|                                                                                                     |
| Statistics                                                                                          |
|  planed with unknown column statistics

If we set set enable_sync_mv_cost_based_rewrite = false;
the right materialized view can be selected. This variable is introduced by #33699.

What You Expected?

In version 2.1.4, advertiser_uv will be selected.

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant