Fix alter policy failed (#33910)
This commit is contained in:
@ -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();
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user