diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java index ad4ca612a57cd9..1f38ce045eeffd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java @@ -45,6 +45,7 @@ import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.google.gson.annotations.SerializedName; @@ -529,6 +530,9 @@ public JsonElement serialize(PartitionKey partitionKey, java.lang.reflect.Type r jsonArray.add(typeAndKey); } + // for compatibility in the future + jsonArray.add(new JsonPrimitive("unused")); + return jsonArray; } @@ -541,7 +545,7 @@ public PartitionKey deserialize(JsonElement json, java.lang.reflect.Type typeOfT PartitionKey partitionKey = new PartitionKey(); JsonArray jsonArray = json.getAsJsonArray(); - for (int i = 0; i < jsonArray.size(); i++) { + for (int i = 0; i < jsonArray.size() - 1; i++) { PrimitiveType type = null; type = context.deserialize(jsonArray.get(i).getAsJsonArray().get(0), PrimitiveType.class); LiteralExpr key = context.deserialize(jsonArray.get(i).getAsJsonArray().get(1), Expr.class); @@ -572,6 +576,8 @@ public PartitionKey deserialize(JsonElement json, java.lang.reflect.Type typeOfT partitionKey.types.add(type); partitionKey.keys.add(key); } + + // ignore the last element return partitionKey; } }