This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 9a77e41d8f1 branch-4.1: [Fix](user-property) Preserve legacy user 
properties during desrialization #65781 (#66098)
9a77e41d8f1 is described below

commit 9a77e41d8f17eb6df50a92eb64bc07cdb7db13db
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Aug 3 10:30:36 2026 +0800

    branch-4.1: [Fix](user-property) Preserve legacy user properties during 
desrialization #65781 (#66098)
    
    Cherry-picked from #65781
    
    Co-authored-by: linrrarity <[email protected]>
---
 .../mysql/privilege/CommonUserProperties.java      |  4 +-
 .../mysql/privilege/CommonUserPropertiesTest.java  | 86 ++++++++++++++++++++++
 2 files changed, 88 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java
 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java
index 277a206aa87..ed75a85078f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CommonUserProperties.java
@@ -45,12 +45,12 @@ public class CommonUserProperties implements 
GsonPostProcessable {
     private long maxQueryInstances = -1;
     @SerializedName(value = "pfei", alternate = 
{"parallelFragmentExecInstanceNum"})
     private int parallelFragmentExecInstanceNum = -1;
-    @SerializedName(value = "sbr", alternate = {"sqlBlockRule"})
+    @SerializedName(value = "sbr", alternate = {"sqlBlockRule", 
"sqlBlockRules"})
     private String sqlBlockRules = "";
     @SerializedName(value = "crl", alternate = {"cpuResourceLimit"})
     private int cpuResourceLimit = -1;
     // The tag of the resource that the user is allowed to use
-    @SerializedName(value = "rt", alternate = {"resourceTag"})
+    @SerializedName(value = "rt", alternate = {"resourceTag", "resourceTags"})
     private Set<Tag> resourceTags = Sets.newHashSet();
     // user level exec_mem_limit, if > 0, will overwrite the exec_mem_limit in 
session variable
     @SerializedName(value = "eml", alternate = {"execMemLimit"})
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/CommonUserPropertiesTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/CommonUserPropertiesTest.java
new file mode 100644
index 00000000000..dcaab9c2ac4
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/CommonUserPropertiesTest.java
@@ -0,0 +1,86 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.mysql.privilege;
+
+import org.apache.doris.persist.gson.GsonUtils;
+import org.apache.doris.resource.Tag;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+
+public class CommonUserPropertiesTest {
+    private static final String RESOURCE_TAG_JSON = 
"[{\"type\":\"location\",\"value\":\"group_a\"}]";
+
+    @Test
+    public void testDeserializeResourceTagsFromAllFieldNames() {
+        for (String fieldName : new String[] {"rt", "resourceTag", 
"resourceTags"}) {
+            String json = String.format("{\"%s\":%s}", fieldName, 
RESOURCE_TAG_JSON);
+            CommonUserProperties properties = GsonUtils.GSON.fromJson(json, 
CommonUserProperties.class);
+
+            
Assert.assertEquals(Collections.singleton(Tag.createNotCheck(Tag.TYPE_LOCATION, 
"group_a")),
+                    properties.getResourceTags());
+        }
+    }
+
+    @Test
+    public void testDeserializeSqlBlockRulesFromAllFieldNames() {
+        for (String fieldName : new String[] {"sbr", "sqlBlockRule", 
"sqlBlockRules"}) {
+            String json = String.format("{\"%s\":\"rule_a, rule_b\"}", 
fieldName);
+            CommonUserProperties properties = GsonUtils.GSON.fromJson(json, 
CommonUserProperties.class);
+
+            Assert.assertEquals("rule_a, rule_b", 
properties.getSqlBlockRules());
+            Assert.assertArrayEquals(new String[] {"rule_a", "rule_b"}, 
properties.getSqlBlockRulesSplit());
+        }
+    }
+
+    @Test
+    public void testDeserializeLegacyCommonUserProperties() {
+        String json = "{"
+                + "\"maxConn\":101,"
+                + "\"maxQueryInstances\":102,"
+                + "\"parallelFragmentExecInstanceNum\":103,"
+                + "\"sqlBlockRules\":\"rule_a, rule_b\","
+                + "\"cpuResourceLimit\":104,"
+                + "\"resourceTags\":" + RESOURCE_TAG_JSON + ","
+                + "\"execMemLimit\":105,"
+                + "\"queryTimeout\":106,"
+                + "\"insertTimeout\":107,"
+                + "\"workloadGroup\":\"legacy_group\","
+                + "\"enablePreferCachedRowset\":true,"
+                + "\"queryFreshnessTolerance\":108"
+                + "}";
+        CommonUserProperties properties = GsonUtils.GSON.fromJson(json, 
CommonUserProperties.class);
+
+        Assert.assertEquals(101L, properties.getMaxConn());
+        Assert.assertEquals(102L, properties.getMaxQueryInstances());
+        Assert.assertEquals(103, 
properties.getParallelFragmentExecInstanceNum());
+        Assert.assertEquals("rule_a, rule_b", properties.getSqlBlockRules());
+        Assert.assertArrayEquals(new String[] {"rule_a", "rule_b"}, 
properties.getSqlBlockRulesSplit());
+        Assert.assertEquals(104, properties.getCpuResourceLimit());
+        
Assert.assertEquals(Collections.singleton(Tag.createNotCheck(Tag.TYPE_LOCATION, 
"group_a")),
+                properties.getResourceTags());
+        Assert.assertEquals(105L, properties.getExecMemLimit());
+        Assert.assertEquals(106, properties.getQueryTimeout());
+        Assert.assertEquals(107, properties.getInsertTimeout());
+        Assert.assertEquals("legacy_group", properties.getWorkloadGroup());
+        Assert.assertTrue(properties.getEnablePreferCachedRowset());
+        Assert.assertEquals(108L, properties.getQueryFreshnessToleranceMs());
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to