This is an automated email from the ASF dual-hosted git repository. kangkaisen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new 77a7037 Fix cooldown timestamp bug (#3336) 77a7037 is described below commit 77a7037346e7dfa3c962b7a4e7c4d4e227f380ac Author: kangpinghuang <kphu...@163.com> AuthorDate: Sat Apr 18 22:47:22 2020 +0800 Fix cooldown timestamp bug (#3336) 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 +- .../java/org/apache/doris/common/PropertyAnalyzerTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 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 f2a2a0d..118288c 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 class PropertyAnalyzer { } 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 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 3aaaf20..9ff9e6f 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.AggregateType; 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 class PropertyAnalyzerTest { properties.put(PropertyAnalyzer.PROPERTIES_BF_FPP, "0.05"); Assert.assertEquals(0.05, PropertyAnalyzer.analyzeBloomFilterFpp(properties), 0.0001); } + + @Test + public void testStorageMedium() throws AnalysisException { + Map<String, String> 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); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org