[Dynamic Partition] Support for automatically drop partitions (#3081)
This commit is contained in:
@ -80,6 +80,7 @@ public class DynamicPartitionTableTest {
|
||||
properties.put(DynamicPartitionProperty.ENABLE, "true");
|
||||
properties.put(DynamicPartitionProperty.PREFIX, "p");
|
||||
properties.put(DynamicPartitionProperty.TIME_UNIT, "day");
|
||||
properties.put(DynamicPartitionProperty.START, "-3");
|
||||
properties.put(DynamicPartitionProperty.END, "3");
|
||||
properties.put(DynamicPartitionProperty.BUCKETS, "30");
|
||||
|
||||
@ -293,6 +294,50 @@ public class DynamicPartitionTableTest {
|
||||
catalog.createTable(stmt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissSTART(@Injectable SystemInfoService systemInfoService,
|
||||
@Injectable PaloAuth paloAuth,
|
||||
@Injectable EditLog editLog) throws UserException {
|
||||
new Expectations(catalog) {
|
||||
{
|
||||
catalog.getDb(dbTableName.getDb());
|
||||
minTimes = 0;
|
||||
result = db;
|
||||
|
||||
Catalog.getCurrentSystemInfo();
|
||||
minTimes = 0;
|
||||
result = systemInfoService;
|
||||
|
||||
systemInfoService.checkClusterCapacity(anyString);
|
||||
minTimes = 0;
|
||||
systemInfoService.seqChooseBackendIds(anyInt, true, true, anyString);
|
||||
minTimes = 0;
|
||||
result = beIds;
|
||||
|
||||
catalog.getAuth();
|
||||
minTimes = 0;
|
||||
result = paloAuth;
|
||||
paloAuth.checkTblPriv((ConnectContext) any, anyString, anyString, PrivPredicate.CREATE);
|
||||
minTimes = 0;
|
||||
result = true;
|
||||
|
||||
catalog.getEditLog();
|
||||
minTimes = 0;
|
||||
result = editLog;
|
||||
}
|
||||
};
|
||||
|
||||
properties.remove(DynamicPartitionProperty.START);
|
||||
|
||||
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
|
||||
new KeysDesc(KeysType.AGG_KEYS, columnNames),
|
||||
new RangePartitionDesc(Lists.newArrayList("key1"), singleRangePartitionDescs),
|
||||
new HashDistributionDesc(1, Lists.newArrayList("key1")), properties, null, "");
|
||||
stmt.analyze(analyzer);
|
||||
|
||||
catalog.createTable(stmt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissEnd(@Injectable SystemInfoService systemInfoService,
|
||||
@Injectable PaloAuth paloAuth,
|
||||
|
||||
@ -49,6 +49,7 @@ public class TablePropertyTest {
|
||||
HashMap<String, String> properties = new HashMap<>();
|
||||
properties.put(DynamicPartitionProperty.ENABLE, "true");
|
||||
properties.put(DynamicPartitionProperty.TIME_UNIT, "day");
|
||||
properties.put(DynamicPartitionProperty.START, "-3");
|
||||
properties.put(DynamicPartitionProperty.END, "3");
|
||||
properties.put(DynamicPartitionProperty.PREFIX, "p");
|
||||
properties.put(DynamicPartitionProperty.BUCKETS, "30");
|
||||
@ -67,6 +68,7 @@ public class TablePropertyTest {
|
||||
Assert.assertEquals(readDynamicPartitionProperty.getEnable(), dynamicPartitionProperty.getEnable());
|
||||
Assert.assertEquals(readDynamicPartitionProperty.getBuckets(), dynamicPartitionProperty.getBuckets());
|
||||
Assert.assertEquals(readDynamicPartitionProperty.getPrefix(), dynamicPartitionProperty.getPrefix());
|
||||
Assert.assertEquals(readDynamicPartitionProperty.getStart(), dynamicPartitionProperty.getStart());
|
||||
Assert.assertEquals(readDynamicPartitionProperty.getEnd(), dynamicPartitionProperty.getEnd());
|
||||
Assert.assertEquals(readDynamicPartitionProperty.getTimeUnit(), dynamicPartitionProperty.getTimeUnit());
|
||||
in.close();
|
||||
|
||||
@ -49,6 +49,7 @@ public class ModifyDynamicPartitionInfoTest {
|
||||
HashMap<String, String> properties = new HashMap<>();
|
||||
properties.put(DynamicPartitionProperty.ENABLE, "true");
|
||||
properties.put(DynamicPartitionProperty.TIME_UNIT, "day");
|
||||
properties.put(DynamicPartitionProperty.START, "-3");
|
||||
properties.put(DynamicPartitionProperty.END, "3");
|
||||
properties.put(DynamicPartitionProperty.PREFIX, "p");
|
||||
properties.put(DynamicPartitionProperty.BUCKETS, "30");
|
||||
|
||||
@ -125,6 +125,38 @@ public class QueryPlanTest {
|
||||
"PROPERTIES (\n" +
|
||||
"\"replication_num\" = \"1\"\n" +
|
||||
");");
|
||||
|
||||
createTable("CREATE TABLE test.`dynamic_partition` (\n" +
|
||||
" `k1` date NULL COMMENT \"\",\n" +
|
||||
" `k2` smallint(6) NULL COMMENT \"\",\n" +
|
||||
" `k3` int(11) NULL COMMENT \"\",\n" +
|
||||
" `k4` bigint(20) NULL COMMENT \"\",\n" +
|
||||
" `k5` decimal(9, 3) NULL COMMENT \"\",\n" +
|
||||
" `k6` char(5) NULL COMMENT \"\",\n" +
|
||||
" `k10` date NULL COMMENT \"\",\n" +
|
||||
" `k11` datetime NULL COMMENT \"\",\n" +
|
||||
" `k7` varchar(20) NULL COMMENT \"\",\n" +
|
||||
" `k8` double MAX NULL COMMENT \"\",\n" +
|
||||
" `k9` float SUM NULL COMMENT \"\"\n" +
|
||||
") ENGINE=OLAP\n" +
|
||||
"AGGREGATE KEY(`k1`, `k2`, `k3`, `k4`, `k5`, `k6`, `k10`, `k11`, `k7`)\n" +
|
||||
"COMMENT \"OLAP\"\n" +
|
||||
"PARTITION BY RANGE (k1)\n" +
|
||||
"(\n" +
|
||||
"PARTITION p1 VALUES LESS THAN (\"2014-01-01\"),\n" +
|
||||
"PARTITION p2 VALUES LESS THAN (\"2014-06-01\"),\n" +
|
||||
"PARTITION p3 VALUES LESS THAN (\"2014-12-01\")\n" +
|
||||
")\n" +
|
||||
"DISTRIBUTED BY HASH(`k1`) BUCKETS 5\n" +
|
||||
"PROPERTIES (\n" +
|
||||
"\"replication_num\" = \"1\",\n" +
|
||||
"\"dynamic_partition.enable\" = \"true\",\n" +
|
||||
"\"dynamic_partition.start\" = \"-3\",\n" +
|
||||
"\"dynamic_partition.end\" = \"3\",\n" +
|
||||
"\"dynamic_partition.time_unit\" = \"day\",\n" +
|
||||
"\"dynamic_partition.prefix\" = \"p\",\n" +
|
||||
"\"dynamic_partition.buckets\" = \"1\"\n" +
|
||||
");");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
||||
Reference in New Issue
Block a user