From bc25ed153a70f5993e6b0c4847ab5f361b047054 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 07:08:33 +0000 Subject: [PATCH] [BugFix] Fix partition live number not working (backport #49213) (#49241) Co-authored-by: wyb --- .../com/starrocks/catalog/TableProperty.java | 3 +++ .../starrocks/catalog/TablePropertyTest.java | 24 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/catalog/TableProperty.java b/fe/fe-core/src/main/java/com/starrocks/catalog/TableProperty.java index 442ddbcd5f232..8f7d401b1ce66 100644 --- a/fe/fe-core/src/main/java/com/starrocks/catalog/TableProperty.java +++ b/fe/fe-core/src/main/java/com/starrocks/catalog/TableProperty.java @@ -435,6 +435,9 @@ public TableProperty buildReplicationNum() { } public TableProperty buildPartitionTTL() { + if (partitionTTLNumber != INVALID) { + return this; + } partitionTTLNumber = Integer.parseInt(properties.getOrDefault(PropertyAnalyzer.PROPERTIES_PARTITION_TTL_NUMBER, String.valueOf(INVALID))); return this; diff --git a/fe/fe-core/src/test/java/com/starrocks/catalog/TablePropertyTest.java b/fe/fe-core/src/test/java/com/starrocks/catalog/TablePropertyTest.java index bb317e573433c..254de60808ec0 100644 --- a/fe/fe-core/src/test/java/com/starrocks/catalog/TablePropertyTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/catalog/TablePropertyTest.java @@ -75,7 +75,6 @@ public void testNormal() throws IOException { in.close(); } - @Test public void testBuildDataCachePartitionDuration() throws IOException { // 1. Write objects to file @@ -97,4 +96,27 @@ public void testBuildDataCachePartitionDuration() throws IOException { in.close(); } + @Test + public void testPartitionTTLNumberSerialization() throws IOException { + // 1. Write objects to file + File file = new File(fileName); + file.createNewFile(); + DataOutputStream out = new DataOutputStream(new FileOutputStream(file)); + + HashMap properties = new HashMap<>(); + properties.put(PropertyAnalyzer.PROPERTIES_PARTITION_LIVE_NUMBER, "2"); + TableProperty tableProperty = new TableProperty(properties); + tableProperty.buildPartitionLiveNumber(); + tableProperty.buildPartitionTTL(); + Assert.assertEquals(2, tableProperty.getPartitionTTLNumber()); + tableProperty.write(out); + out.flush(); + out.close(); + + // 2. Read objects from file + DataInputStream in = new DataInputStream(new FileInputStream(file)); + TableProperty readTableProperty = TableProperty.read(in); + Assert.assertEquals(2, readTableProperty.getPartitionTTLNumber()); + in.close(); + } }