Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] add a switch to control default refresh immediate #37093

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions fe/fe-core/src/main/java/com/starrocks/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2605,6 +2605,11 @@ public class Config extends ConfigBase {
@ConfField(mutable = true)
public static int default_mv_partition_refresh_number = 1;

@ConfField(mutable = true,
comment = "The default behavior of whether REFRESH IMMEDIATE or not, " +
"which would refresh the materialized view after creating")
public static boolean default_mv_refresh_immediate = true;

/**
* Whether analyze the mv after refresh in async mode.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ public class RefreshSchemeClause extends AlterTableClause {
protected MaterializedView.RefreshMoment moment;
protected final NodePosition pos;

public RefreshSchemeClause(MaterializedView.RefreshType type) {
this(type, NodePosition.ZERO);
}

public RefreshSchemeClause(MaterializedView.RefreshType type, NodePosition pos) {
this(type, pos, MaterializedView.RefreshMoment.IMMEDIATE);
}

public RefreshSchemeClause(MaterializedView.RefreshType type, NodePosition pos, MaterializedView.RefreshMoment moment) {
super(AlterOpType.REFRESH_SCHEMA, pos);
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6602,9 +6602,13 @@ public ParseNode visitRefreshSchemeDesc(StarRocksParser.RefreshSchemeDescContext
LocalDateTime startTime = LocalDateTime.now();
IntervalLiteral intervalLiteral = null;
NodePosition pos = createPos(context);
MaterializedView.RefreshMoment refreshMoment = MaterializedView.RefreshMoment.IMMEDIATE;
MaterializedView.RefreshMoment refreshMoment =
Config.default_mv_refresh_immediate ?
MaterializedView.RefreshMoment.IMMEDIATE : MaterializedView.RefreshMoment.DEFERRED;
if (context.DEFERRED() != null) {
refreshMoment = MaterializedView.RefreshMoment.DEFERRED;
} else if (context.IMMEDIATE() != null) {
refreshMoment = MaterializedView.RefreshMoment.IMMEDIATE;
}
if (context.ASYNC() != null) {
boolean defineStartTime = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public static void beforeClass() throws Exception {
// Use sync analyze
Config.mv_auto_analyze_async = false;

// Default REFRESH DEFERRED
Config.default_mv_refresh_immediate = false;

PseudoCluster.getOrCreateWithRandomPort(true, 3);
GlobalStateMgr.getCurrentState().getTabletChecker().setInterval(1000);
cluster = PseudoCluster.getInstance();
Expand Down
Loading