Skip to content

[Bug] (mtmv) Unable to find a suitable base table for partitioning when there are both valid and invalid expressions #38366

@liutang123

Description

@liutang123

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions