Fix alter policy failed (#33910)

This commit is contained in:
wangbo
2024-04-22 12:52:23 +08:00
committed by yiguolei
parent a050513c91
commit 299d069da9
6 changed files with 47 additions and 4 deletions

View File

@ -508,6 +508,7 @@ public class SchemaTable extends Table {
.column("PRIORITY", ScalarType.createType(PrimitiveType.INT))
.column("ENABLED", ScalarType.createType(PrimitiveType.BOOLEAN))
.column("VERSION", ScalarType.createType(PrimitiveType.INT))
.column("WORKLOAD_GROUP", ScalarType.createStringType())
.build()))
.build();

View File

@ -172,7 +172,7 @@ public class WorkloadSchedPolicy implements Writable, GsonPostProcessable {
return retType;
}
public void updateProperty(Map<String, String> property, List<Long> wgIdList) {
public void updatePropertyIfNotNull(Map<String, String> property, List<Long> wgIdList) {
String enabledStr = property.get(ENABLED);
if (enabledStr != null) {
this.enabled = Boolean.parseBoolean(enabledStr);
@ -183,7 +183,11 @@ public class WorkloadSchedPolicy implements Writable, GsonPostProcessable {
this.priority = Integer.parseInt(priorityStr);
}
if (wgIdList.size() > 0) {
String workloadGroupIdStr = property.get(WORKLOAD_GROUP);
// workloadGroupIdStr != null means user set workload group property,
// then we should overwrite policy's workloadGroupIdList
// if workloadGroupIdStr.length == 0, it means the policy should match all query.
if (workloadGroupIdStr != null) {
this.workloadGroupIdList = wgIdList;
}
}

View File

@ -435,7 +435,7 @@ public class WorkloadSchedPolicyMgr implements Writable, GsonPostProcessable {
Map<String, String> properties = alterStmt.getProperties();
List<Long> wgIdList = new ArrayList<>();
checkProperties(properties, wgIdList);
policy.updateProperty(properties, wgIdList);
policy.updatePropertyIfNotNull(properties, wgIdList);
policy.incrementVersion();
Env.getCurrentEnv().getEditLog().logAlterWorkloadSchedPolicy(policy);
} finally {