Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,6 +83,14 @@ public Set<BaseTableInfo> getBaseViews() {
return baseViews;
}

@Override

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for this exact compatibility path. The existing MTMVRelationTest creates a fresh MTMV, so baseViewsOneLevel is already populated and that test would have passed before this PR. The reported failure only happens after Gson deserializes old MTMV metadata where the bvol field is absent; a focused test should deserialize such JSON through GsonUtils.GSON and assert getBaseViewsOneLevel() is non-null before MetadataGenerator streams it.

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{"
Expand Down
Loading