From a0bea7cfbac50f097848cae56c11af86be2f95eb Mon Sep 17 00:00:00 2001 From: Yongqiang YANG Date: Fri, 5 Jul 2024 00:09:06 +0800 Subject: [PATCH] fix --- .../main/java/org/apache/doris/catalog/PartitionKey.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } }