From 77ea907b5480c29393bea3197eef54f47f20d64c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 11:30:47 +0800 Subject: [PATCH] =?UTF-8?q?branch-2.1:=20[Bug](materialized-view)=20Fixed?= =?UTF-8?q?=20the=20problem=20of=20using=20drop=20table=20force=20and=20cr?= =?UTF-8?q?eate=20mv=20stmt=20at=20the=E2=80=A6=20#41580=20(#50133)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-picked from #41580 Co-authored-by: Pxl --- .../org/apache/doris/alter/RollupJobV2.java | 6 ++- .../mv_with_force_drop.groovy | 52 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 regression-test/suites/mv_p0/mv_with_force_drop/mv_with_force_drop.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java index 93057455d2..b27d896e9a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java @@ -886,7 +886,11 @@ public class RollupJobV2 extends AlterJobV2 implements GsonPostProcessable { stmt.analyze(analyzer); } catch (Exception e) { // Under normal circumstances, the stmt will not fail to analyze. - throw new IOException("error happens when parsing create materialized view stmt: " + stmt, e); + // In some cases (such as drop table force), analyze may fail because cancel is + // not included in the checkpoint. + jobState = JobState.CANCELLED; + LOG.warn("error happens when parsing create materialized view stmt: " + stmt, e); + return; } setColumnsDefineExpr(stmt.getMVColumnItemList()); } diff --git a/regression-test/suites/mv_p0/mv_with_force_drop/mv_with_force_drop.groovy b/regression-test/suites/mv_p0/mv_with_force_drop/mv_with_force_drop.groovy new file mode 100644 index 0000000000..69b13bfb87 --- /dev/null +++ b/regression-test/suites/mv_p0/mv_with_force_drop/mv_with_force_drop.groovy @@ -0,0 +1,52 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("mv_with_force_drop") { + sql """ + drop table if exists test_table_t1; + """ + + sql """ + CREATE TABLE test_table_t1 ( + a1 varchar(65533) NULL default '123', + a2 varchar(64) NULL default '', + a3 varchar(65533) NULL default '', + a4 varchar(65533) NULL default '', + a5 varchar(64) default '2023-01-31', + a6 varchar(64) default '' + ) ENGINE = OLAP + DUPLICATE KEY(a1) + DISTRIBUTED BY HASH(a1) BUCKETS 3 + PROPERTIES ( + "replication_allocation"="tag.location.default:1", + "is_being_synced"="false", + "storage_format"="V2", + "disable_auto_compaction"="false", + "enable_single_replica_compaction"="false" + ); + """ + + sql """ insert into test_table_t1 values(); """ + // create mv and do not wait ready + sql """ CREATE MATERIALIZED VIEW test_table_view As + select a1,a3,a4,DATE_FORMAT(a5, 'yyyyMMdd') QUERY_TIME,DATE_FORMAT(a6 ,'yyyyMMdd') CREATE_TIME + from test_table_t1 where DATE_FORMAT(a5, 'yyyyMMdd') =20230131; """ + // drop table force immediately + sql """ + drop table if exists test_table_t1 force; + """ +}