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.
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user