[Bug] Fix bug that NPE thrown when adding partition for table with MV (#7069)
The `defineExpr` in `Column` must be analyzed before calling its `treeToThrift` method. And fro CreateReplicaTask, no need to set `defineExpr` in TColumn.
This commit is contained in:
@ -404,6 +404,7 @@ public class SlotRef extends Expr {
|
||||
|
||||
@Override
|
||||
public boolean isNullable() {
|
||||
Preconditions.checkNotNull(desc);
|
||||
return desc.getIsNullable();
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class Column implements Writable {
|
||||
private List<Column> children;
|
||||
// Define expr may exist in two forms, one is analyzed, and the other is not analyzed.
|
||||
// Currently, analyzed define expr is only used when creating materialized views, so the define expr in RollupJob must be analyzed.
|
||||
// In other cases, such as define expr in `MaterializedIndexMeta`, it may not be analyzed after being relayed.
|
||||
// In other cases, such as define expr in `MaterializedIndexMeta`, it may not be analyzed after being replayed.
|
||||
private Expr defineExpr; // use to define column in materialize view
|
||||
@SerializedName(value = "visible")
|
||||
private boolean visible;
|
||||
@ -344,13 +344,13 @@ public class Column implements Writable {
|
||||
tColumn.setVisible(visible);
|
||||
tColumn.setChildrenColumn(new ArrayList<>());
|
||||
toChildrenThrift(this, tColumn);
|
||||
|
||||
// The define expr does not need to be serialized here for now.
|
||||
// At present, only serialized(analyzed) define expr is directly used when creating a materialized view.
|
||||
// It will not be used here, but through another structure `TAlterMaterializedViewParam`.
|
||||
if (this.defineExpr != null) {
|
||||
tColumn.setDefineExpr(this.defineExpr.treeToThrift());
|
||||
}
|
||||
|
||||
// ATTN:
|
||||
// Currently, this `toThrift()` method is only used from CreateReplicaTask.
|
||||
// And CreateReplicaTask does not need `defineExpr` field.
|
||||
// The `defineExpr` is only used when creating `TAlterMaterializedViewParam`, which is in `AlterReplicaTask`.
|
||||
// And when creating `TAlterMaterializedViewParam`, the `defineExpr` is certainly analyzed.
|
||||
// If we need to use `defineExpr` and call defineExpr.treeToThrift(), make sure it is analyzed, or NPE will thrown.
|
||||
return tColumn;
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,6 @@ public class MaterializedIndexMeta implements Writable, GsonPostProcessable {
|
||||
@SerializedName(value = "keysType")
|
||||
private KeysType keysType;
|
||||
@SerializedName(value = "defineStmt")
|
||||
|
||||
private OriginStatement defineStmt;
|
||||
|
||||
public MaterializedIndexMeta(long indexId, List<Column> schema, int schemaVersion, int schemaHash,
|
||||
|
||||
@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Deprecated
|
||||
public class CreateRollupTask extends AgentTask {
|
||||
|
||||
private long baseTableId;
|
||||
|
||||
@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Deprecated
|
||||
public class SchemaChangeTask extends AgentTask {
|
||||
|
||||
private long baseReplicaId;
|
||||
|
||||
Reference in New Issue
Block a user