From a2fe0711e7f5366831f1db78b6a14f825252674f Mon Sep 17 00:00:00 2001 From: yujun Date: Mon, 15 Jun 2026 12:05:56 +0800 Subject: [PATCH] [fix](mtmv) Add null-safety to getBaseViewsOneLevel for backward compatibility (#64412) Introduced by #56423, the field baseViewsOneLevel may be null for MTMVs created before that PR. This causes NPE when querying information_schema.view_dependency: Cannot invoke java.util.Set.stream() because the return value of org.apache.doris.mtmv.MTMVRelation.getBaseViewsOneLevel() is null baseViewsOneLevel is currently only used for tablefunction/MetadataGenerator, so this change is safe. --------- Co-authored-by: Claude Fable 5 --- .../java/org/apache/doris/mtmv/MTMVRelation.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java index 46caf032f53dc7..452733cf7a7486 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java @@ -18,13 +18,16 @@ package org.apache.doris.mtmv; import org.apache.doris.datasource.CatalogMgr; +import org.apache.doris.persist.gson.GsonPostProcessable; import com.google.gson.annotations.SerializedName; import org.apache.commons.collections4.CollectionUtils; +import java.io.IOException; +import java.util.HashSet; import java.util.Set; -public class MTMVRelation { +public class MTMVRelation implements GsonPostProcessable { // t1 => v1 => v2 // t2 => mv1 // mv1 join v2 => mv2 @@ -80,6 +83,14 @@ public Set getBaseViews() { return baseViews; } + @Override + public void gsonPostProcess() throws IOException { + // For backward compatibility: previously created MTMV may not have baseViewsOneLevel + if (baseViewsOneLevel == null) { + baseViewsOneLevel = baseViews == null ? new HashSet<>() : new HashSet<>(baseViews); + } + } + // toString() is not easy to find where to call the method public String toInfoString() { return "MTMVRelation{"