From f5dd6e90cbfdbd6e0475a35f536c78628d4ac148 Mon Sep 17 00:00:00 2001 From: huangkangping Date: Thu, 16 Apr 2020 17:26:52 +0800 Subject: [PATCH 1/2] fix cooldown timestamp bug when add a parition with storage_cooldown_time property like this: alter table tablexxx ADD PARTITION p20200421 VALUES LESS THAN("1588262400") ("storage_medium" = "SSD", "storage_cooldown_time" = "2020-05-01 00:00:00"); and show partitions from tablexxx; the CooldownTime is wrong: 2610-02-17 10:16:40, and what is more, the storage migration is based on the wrong timestamp. The reason is that the result of DateLiteral.getLongValue is not timestamp. --- .../java/org/apache/doris/common/util/PropertyAnalyzer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index f2a2a0dd3a9826..118288c3ab598a 100644 --- a/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -110,7 +110,7 @@ public static DataProperty analyzeDataProperty(Map properties, D } else if (!hasCooldown && key.equalsIgnoreCase(PROPERTIES_STORAGE_COLDOWN_TIME)) { hasCooldown = true; DateLiteral dateLiteral = new DateLiteral(value, Type.DATETIME); - coolDownTimeStamp = dateLiteral.getLongValue(); + coolDownTimeStamp = dateLiteral.unixTimestamp(TimeUtils.getTimeZone()); } } // end for properties From 3672a23425043b4902e971ead4e476134dd56e66 Mon Sep 17 00:00:00 2001 From: huangkangping Date: Fri, 17 Apr 2020 19:39:11 +0800 Subject: [PATCH 2/2] add unit test for cool down time --- .../org/apache/doris/common/PropertyAnalyzerTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java b/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java index 3aaaf203d2dec5..9ff9e6fc05c415 100644 --- a/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java +++ b/fe/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java @@ -21,12 +21,14 @@ import org.apache.doris.catalog.Column; import org.apache.doris.catalog.ScalarType; import org.apache.doris.catalog.PrimitiveType; +import org.apache.doris.catalog.DataProperty; import org.apache.doris.common.util.PropertyAnalyzer; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import org.apache.doris.thrift.TStorageMedium; import org.junit.Assert; import org.junit.Test; @@ -115,4 +117,13 @@ public void testBfFpp() throws AnalysisException { properties.put(PropertyAnalyzer.PROPERTIES_BF_FPP, "0.05"); Assert.assertEquals(0.05, PropertyAnalyzer.analyzeBloomFilterFpp(properties), 0.0001); } + + @Test + public void testStorageMedium() throws AnalysisException { + Map properties = Maps.newHashMap(); + properties.put(PropertyAnalyzer.PROPERTIES_STORAGE_MEDIUM, "SSD"); + properties.put(PropertyAnalyzer.PROPERTIES_STORAGE_COLDOWN_TIME, "2020-05-01 00:00:00"); + DataProperty dataProperty = PropertyAnalyzer.analyzeDataProperty(properties, new DataProperty(TStorageMedium.SSD)); + Assert.assertEquals(1588262400, dataProperty.getCooldownTimeMs() / 1000); + } }