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] (mtmv) Unable to find a suitable base table for partitioning when there are both valid and invalid expressions #38366

Closed
3 tasks done
liutang123 opened this issue Jul 25, 2024 · 0 comments · Fixed by #38367

Comments

@liutang123
Copy link
Contributor

Search before asking

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

Version

2.1

What's Wrong?

reproduce:

CREATE TABLE `test_t` (
  `id` VARCHAR(36) NOT NULL COMMENT 'id',
  `created_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ''
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT ''
PARTITION BY RANGE(`created_time`)
(PARTITION P_2024071713 VALUES [('2024-07-17 13:00:00'), ('2024-07-17 14:00:00')),
PARTITION P_2024071714 VALUES [('2024-07-17 14:00:00'), ('2024-07-17 15:00:00')))
DISTRIBUTED BY HASH(`id`) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
CREATE MATERIALIZED VIEW test_mtmv
        BUILD IMMEDIATE REFRESH AUTO ON MANUAL
        partition by(date_trunc(created_time_minute, 'day'))
        DISTRIBUTED BY RANDOM BUCKETS 3
        PROPERTIES ('replication_num' = '1') 
        AS 
select  id 
        ,date_trunc(created_time, 'minute') as created_time_minute
        ,min(created_time) as start_time
        ,if(count(id) > 0, 1, 0) as status
        from test_t 
        group by id, date_trunc(created_time, 'minute');

An error occurs:

ERROR 1105 (HY000): errCode = 2, detailMessage = Unable to find a suitable base table for partitioning, the fail reason is can't not find valid partition track column, because column to check use invalid implicit expression, invalid expression is min(created_time#12)

What You Expected?

test_t should be selected as base table.
date_trunc(created_time, 'minute') should pass the check and min(created_time) should be ignore.

How to Reproduce?

Refer to the description above.

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
1 participant