This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 43d3266c7fe branch-3.0: [fix](mtmv) Fix exception when calc mtmv
function dependency but the table in mtmv def sql is deleted #50096 (#50122)
43d3266c7fe is described below
commit 43d3266c7fecaa64537419669787b33de3af4620
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Apr 18 11:19:21 2025 +0800
branch-3.0: [fix](mtmv) Fix exception when calc mtmv function dependency
but the table in mtmv def sql is deleted #50096 (#50122)
Cherry-picked from #50096
Co-authored-by: seawinde <[email protected]>
---
.../src/main/java/org/apache/doris/catalog/MTMV.java | 3 ++-
.../src/main/java/org/apache/doris/mtmv/MTMVCache.java | 3 ++-
.../rules/exploration/mv/AsyncMaterializationContext.java | 3 +--
.../nereids/trees/plans/logical/LogicalOlapScan.java | 11 +++++------
regression-test/data/mtmv_p0/test_env_db_dropped_mtmv.out | Bin 0 -> 127 bytes
.../suites/mtmv_p0/test_env_db_dropped_mtmv.groovy | 4 ++++
6 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
index d96a4997a80..716e00b10f2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
@@ -310,7 +310,8 @@ public class MTMV extends OlapTable {
/**
* Called when in query, Should use one connection context in query
*/
- public MTMVCache getOrGenerateCache(ConnectContext connectionContext)
throws AnalysisException {
+ public MTMVCache getOrGenerateCache(ConnectContext connectionContext)
throws
+ org.apache.doris.nereids.exceptions.AnalysisException {
readMvLock();
try {
if (cache != null) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCache.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCache.java
index bc99fe8bfd1..94fd5415341 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCache.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCache.java
@@ -20,6 +20,7 @@ package org.apache.doris.mtmv;
import org.apache.doris.nereids.CascadesContext;
import org.apache.doris.nereids.NereidsPlanner;
import org.apache.doris.nereids.StatementContext;
+import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.jobs.executor.Rewriter;
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.properties.PhysicalProperties;
@@ -97,7 +98,7 @@ public class MTMVCache {
public static MTMVCache from(String defSql,
ConnectContext createCacheContext,
boolean needCost, boolean needLock,
- ConnectContext currentContext) {
+ ConnectContext currentContext) throws AnalysisException {
StatementContext mvSqlStatementContext = new
StatementContext(createCacheContext,
new OriginStatement(defSql, 0));
if (!needLock) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
index 593ad986ca7..8da199efc5b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
@@ -19,7 +19,6 @@ package org.apache.doris.nereids.rules.exploration.mv;
import org.apache.doris.catalog.MTMV;
import org.apache.doris.catalog.Table;
-import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Id;
import org.apache.doris.common.Pair;
import org.apache.doris.mtmv.MTMVCache;
@@ -102,7 +101,7 @@ public class AsyncMaterializationContext extends
MaterializationContext {
MTMVCache mtmvCache;
try {
mtmvCache =
mtmv.getOrGenerateCache(cascadesContext.getConnectContext());
- } catch (AnalysisException e) {
+ } catch (Exception e) {
LOG.warn(String.format("get mv plan statistics fail,
materialization qualifier is %s",
generateMaterializationIdentifier()), e);
return Optional.empty();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
index 6f89af71d7b..76fac7886e1 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
@@ -21,7 +21,6 @@ import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.MTMV;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Table;
-import org.apache.doris.common.AnalysisException;
import org.apache.doris.mtmv.MTMVCache;
import org.apache.doris.nereids.memo.GroupExpression;
import org.apache.doris.nereids.properties.DataTrait;
@@ -536,7 +535,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan
MTMVCache cache;
try {
cache = mtmv.getOrGenerateCache(ConnectContext.get());
- } catch (AnalysisException e) {
+ } catch (Exception e) {
LOG.warn(String.format("LogicalOlapScan computeUnique fail, mv
name is %s", mtmv.getName()), e);
return;
}
@@ -569,7 +568,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan
MTMVCache cache;
try {
cache = mtmv.getOrGenerateCache(ConnectContext.get());
- } catch (AnalysisException e) {
+ } catch (Exception e) {
LOG.warn(String.format("LogicalOlapScan computeUniform fail,
mv name is %s", mtmv.getName()), e);
return;
}
@@ -590,7 +589,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan
MTMVCache cache;
try {
cache = mtmv.getOrGenerateCache(ConnectContext.get());
- } catch (AnalysisException e) {
+ } catch (Exception e) {
LOG.warn(String.format("LogicalOlapScan computeEqualSet fail,
mv name is %s", mtmv.getName()), e);
return;
}
@@ -611,7 +610,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan
MTMVCache cache;
try {
cache = mtmv.getOrGenerateCache(ConnectContext.get());
- } catch (AnalysisException e) {
+ } catch (Exception e) {
LOG.warn(String.format("LogicalOlapScan computeFd fail, mv
name is %s", mtmv.getName()), e);
return;
}
@@ -632,7 +631,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan
MTMVCache cache;
try {
cache = mtmv.getOrGenerateCache(ConnectContext.get());
- } catch (AnalysisException e) {
+ } catch (Exception e) {
LOG.warn(String.format("LogicalOlapScan constructReplaceMap fail,
mv name is %s", mtmv.getName()), e);
return replaceMap;
}
diff --git a/regression-test/data/mtmv_p0/test_env_db_dropped_mtmv.out
b/regression-test/data/mtmv_p0/test_env_db_dropped_mtmv.out
new file mode 100644
index 00000000000..a3f2c1adc58
Binary files /dev/null and
b/regression-test/data/mtmv_p0/test_env_db_dropped_mtmv.out differ
diff --git a/regression-test/suites/mtmv_p0/test_env_db_dropped_mtmv.groovy
b/regression-test/suites/mtmv_p0/test_env_db_dropped_mtmv.groovy
index 516f5a648c7..5e25cbf4394 100644
--- a/regression-test/suites/mtmv_p0/test_env_db_dropped_mtmv.groovy
+++ b/regression-test/suites/mtmv_p0/test_env_db_dropped_mtmv.groovy
@@ -90,4 +90,8 @@ suite("test_env_db_dropped_mtmv") {
def msg = sql """select ErrorMsg from tasks('type'='mv') where JobName =
'${jobName}' order by CreateTime DESC limit 1"""
logger.info(msg.toString())
assertTrue(msg.toString().contains("does not exist"))
+
+ // select ${dbName2}.${mvName} should not throw exception
+ order_qt_query1 "select count(*) from ${dbName2}.${mvName};"
+ order_qt_query2 "select * from ${dbName2}.${mvName};"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]