Skip to content

[Bug] MTMV refresh failed after base table schema change #53760

@cambyzju

Description

@cambyzju

Search before asking

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

Version

3.x/2.x

What's Wrong?

MTMV refresh failed after base table schema change:
column type not same, please check whether columns of base table have changed, column name is: k2, original type is: varchar(20), current type is: int

What You Expected?

refresh successfully

How to Reproduce?

1. create test table:
> CREATE TABLE `test_base` (
  `k1` int NULL,
  `k2` varchar(20) NULL,
  `v1` int NULL,
  `v2` int NULL
) ENGINE=OLAP
DUPLICATE KEY(`k1`, `k2`);

2. insert test data
> insert into test_base values(1,2,3,4);

3. create async mv:
> CREATE MATERIALIZED VIEW test_mv BUILD IMMEDIATE REFRESH AUTO ON SCHEDULE EVERY 1 MINUTE AS select * from test_base;

> select * from tasks("type"="mv");
+------------------+---------------+--------------------------+---------------+---------+---------------+----------------+---------+----------+---------------------+---------------------+---------------------+------------+---------------------------------------------+-------------+-----------------------+---------------------+---------------+-----------------------------------+
| TaskId           | JobId         | JobName                  | MvId          | MvName  | MvDatabaseId  | MvDatabaseName | Status  | ErrorMsg | CreateTime          | StartTime           | FinishTime          | DurationMs | TaskContext                                 | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress      | LastQueryId                       |
+------------------+---------------+--------------------------+---------------+---------+---------------+----------------+---------+----------+---------------------+---------------------+---------------------+------------+---------------------------------------------+-------------+-----------------------+---------------------+---------------+-----------------------------------+
| 1348636384608302 | 1752722790394 | inner_mtmv_1752722790352 | 1752722790352 | test_mv | 1752722789440 | example_db     | SUCCESS |          | 2025-07-23 13:00:51 | 2025-07-23 13:00:51 | 2025-07-23 13:00:51 | 49         | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE    | ["test_mv"]           | ["test_mv"]         | 100.00% (1/1) | e9705d4767a1462c-be169cc7326158c7 |
+------------------+---------------+--------------------------+---------------+---------+---------------+----------------+---------+----------+---------------------+---------------------+---------------------+------------+---------------------------------------------+-------------+-----------------------+---------------------+---------------+-----------------------------------+

4. alter column
> alter table test_base modify column k2 int key;

5. check refresh task:
> refresh materialized view test_mv auto;

> select * from tasks("type"="mv");
+------------------+---------------+--------------------------+---------------+---------+---------------+----------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------+---------------------+---------------+-----------------------------------+
| TaskId           | JobId         | JobName                  | MvId          | MvName  | MvDatabaseId  | MvDatabaseName | Status  | ErrorMsg                                                                                                                                               | CreateTime          | StartTime           | FinishTime          | DurationMs | TaskContext                                                 | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress      | LastQueryId                       |
+------------------+---------------+--------------------------+---------------+---------+---------------+----------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------+---------------------+---------------+-----------------------------------+
| 1348636384608302 | 1752722790394 | inner_mtmv_1752722790352 | 1752722790352 | test_mv | 1752722789440 | example_db     | SUCCESS |                                                                                                                                                        | 2025-07-23 13:00:51 | 2025-07-23 13:00:51 | 2025-07-23 13:00:51 | 49         | {"triggerMode":"SYSTEM","isComplete":false}                 | COMPLETE    | ["test_mv"]           | ["test_mv"]         | 100.00% (1/1) | e9705d4767a1462c-be169cc7326158c7 |
| 1348696757560301 | 1752722790394 | inner_mtmv_1752722790352 | 1752722790352 | test_mv | 1752722789440 | example_db     | FAILED  | column type not same, please check whether columns of base table have changed, column name is: k2, original type is: varchar(20), current type is: int | 2025-07-23 13:01:52 | 2025-07-23 13:01:52 | \N                  | \N         | {"triggerMode":"SYSTEM","isComplete":false}                 | \N          | \N                    | \N                  | \N            |                                   |
| 1348717481522911 | 1752722790394 | inner_mtmv_1752722790352 | 1752722790352 | test_mv | 1752722789440 | example_db     | FAILED  | column type not same, please check whether columns of base table have changed, column name is: k2, original type is: varchar(20), current type is: int | 2025-07-23 13:02:14 | 2025-07-23 13:02:14 | \N                  | \N         | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | \N          | \N                    | \N                  | \N            |                                   |
+------------------+---------------+--------------------------+---------------+---------+---------------+----------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------+---------------------+---------------+-----------------------------------+

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