This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 37f4bf865fb branch-2.1: [fix](mtmv)When compatibility fails, null
pointers should not be reported #44464 (#44542)
37f4bf865fb is described below
commit 37f4bf865fb3805b2e773b07d4707f93a38c1507
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Nov 26 11:59:29 2024 +0800
branch-2.1: [fix](mtmv)When compatibility fails, null pointers should not
be reported #44464 (#44542)
Cherry-picked from #44464
Co-authored-by: zhangdong <[email protected]>
---
.../src/main/java/org/apache/doris/mtmv/BaseTableInfo.java | 9 +++++++++
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java | 3 +--
.../rules/exploration/mv/InitMaterializationContextHook.java | 12 ++++++++++--
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java
index b6ab6b9f854..9b410470307 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java
@@ -110,6 +110,15 @@ public class BaseTableInfo {
this.tableName = tableName;
}
+ // if compatible failed due catalog dropped, ctlName will be null
+ public boolean isInternalTable() {
+ if (!StringUtils.isEmpty(ctlName)) {
+ return InternalCatalog.INTERNAL_CATALOG_NAME.equals(ctlName);
+ } else {
+ return InternalCatalog.INTERNAL_CATALOG_ID == ctlId;
+ }
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java
index e8413648929..256707fcbd9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java
@@ -28,7 +28,6 @@ import org.apache.doris.common.DdlException;
import org.apache.doris.common.MetaNotFoundException;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.datasource.CatalogMgr;
-import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.nereids.trees.expressions.Expression;
import
org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeExtractAndTransform;
import org.apache.doris.nereids.trees.expressions.literal.DateTimeV2Literal;
@@ -96,7 +95,7 @@ public class MTMVUtil {
public static boolean mtmvContainsExternalTable(MTMV mtmv) {
Set<BaseTableInfo> baseTables =
mtmv.getRelation().getBaseTablesOneLevel();
for (BaseTableInfo baseTableInfo : baseTables) {
- if
(!baseTableInfo.getCtlName().equals(InternalCatalog.INTERNAL_CATALOG_NAME)) {
+ if (!baseTableInfo.isInternalTable()) {
return true;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/InitMaterializationContextHook.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/InitMaterializationContextHook.java
index cacc44a77bf..98866691ad8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/InitMaterializationContextHook.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/InitMaterializationContextHook.java
@@ -33,6 +33,7 @@ import
org.apache.doris.nereids.trees.plans.visitor.TableCollector.TableCollecto
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -105,8 +106,15 @@ public class InitMaterializationContextHook implements
PlannerHook {
private List<MaterializationContext>
createAsyncMaterializationContext(CascadesContext cascadesContext,
Set<TableIf> usedTables) {
- Set<MTMV> availableMTMVs = getAvailableMTMVs(usedTables,
cascadesContext);
- if (availableMTMVs.isEmpty()) {
+ Set<MTMV> availableMTMVs;
+ try {
+ availableMTMVs = getAvailableMTMVs(usedTables, cascadesContext);
+ } catch (Exception e) {
+ LOG.warn(String.format("MaterializationContext getAvailableMTMVs
generate fail, current queryId is %s",
+ cascadesContext.getConnectContext().getQueryIdentifier()),
e);
+ return ImmutableList.of();
+ }
+ if (CollectionUtils.isEmpty(availableMTMVs)) {
LOG.debug("Enable materialized view rewrite but availableMTMVs is
empty, current queryId "
+ "is {}",
cascadesContext.getConnectContext().getQueryIdentifier());
return ImmutableList.of();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]