@@ -1736,6 +1736,8 @@ public void testAutoBuckets() throws Exception {
1736
1736
+ " PROPERTIES (\n "
1737
1737
+ " \" dynamic_partition.enable\" = \" true\" ,\n "
1738
1738
+ " \" dynamic_partition.time_unit\" = \" YEAR\" ,\n "
1739
+ + " \" dynamic_partition.start\" = \" -50\" ,\n "
1740
+ + " \" dynamic_partition.create_history_partition\" = \" true\" ,\n "
1739
1741
+ " \" dynamic_partition.end\" = \" 1\" ,\n "
1740
1742
+ " \" dynamic_partition.prefix\" = \" p\" ,\n "
1741
1743
+ " \" replication_allocation\" = \" tag.location.default: 1\" \n "
@@ -1744,22 +1746,53 @@ public void testAutoBuckets() throws Exception {
1744
1746
Database db = Env .getCurrentInternalCatalog ().getDbOrAnalysisException ("test" );
1745
1747
OlapTable table = (OlapTable ) db .getTableOrAnalysisException ("test_autobucket_dynamic_partition" );
1746
1748
List <Partition > partitions = Lists .newArrayList (table .getAllPartitions ());
1747
- Assert .assertEquals (2 , partitions .size ());
1749
+ Assert .assertEquals (52 , partitions .size ());
1748
1750
for (Partition partition : partitions ) {
1749
1751
Assert .assertEquals (FeConstants .default_bucket_num , partition .getDistributionInfo ().getBucketNum ());
1750
1752
partition .setVisibleVersionAndTime (2L , System .currentTimeMillis ());
1751
1753
}
1752
1754
RebalancerTestUtil .updateReplicaDataSize (1 , 1 , 1 );
1753
1755
1754
- String alterStmt =
1756
+ String alterStmt1 =
1755
1757
"alter table test.test_autobucket_dynamic_partition set ('dynamic_partition.end' = '2')" ;
1756
- ExceptionChecker .expectThrowsNoException (() -> alterTable (alterStmt ));
1758
+ ExceptionChecker .expectThrowsNoException (() -> alterTable (alterStmt1 ));
1757
1759
List <Pair <Long , Long >> tempDynamicPartitionTableInfo = Lists .newArrayList (Pair .of (db .getId (), table .getId ()));
1758
1760
Env .getCurrentEnv ().getDynamicPartitionScheduler ().executeDynamicPartition (tempDynamicPartitionTableInfo , false );
1759
1761
1760
1762
partitions = Lists .newArrayList (table .getAllPartitions ());
1761
1763
partitions .sort (Comparator .comparing (Partition ::getId ));
1762
- Assert .assertEquals (3 , partitions .size ());
1763
- Assert .assertEquals (1 , partitions .get (2 ).getDistributionInfo ().getBucketNum ());
1764
+ Assert .assertEquals (53 , partitions .size ());
1765
+ Assert .assertEquals (1 , partitions .get (partitions .size () - 1 ).getDistributionInfo ().getBucketNum ());
1766
+
1767
+ table .readLock ();
1768
+ try {
1769
+ // first 40 partitions with size 0, then 10 partitions with size 20GB
1770
+ for (int i = 0 ; i < 50 ; i ++) {
1771
+ Partition partition = partitions .get (i );
1772
+ partition .updateVisibleVersion (2L );
1773
+ for (MaterializedIndex idx : partition .getMaterializedIndices (
1774
+ MaterializedIndex .IndexExtState .VISIBLE )) {
1775
+ for (Tablet tablet : idx .getTablets ()) {
1776
+ for (Replica replica : tablet .getReplicas ()) {
1777
+ replica .updateVersion (2L );
1778
+ replica .setDataSize (i < 40 ? 0L : 20L << 30 );
1779
+ replica .setRowCount (1000L );
1780
+ }
1781
+ }
1782
+ }
1783
+ }
1784
+ } finally {
1785
+ table .readUnlock ();
1786
+ }
1787
+
1788
+ String alterStmt2 =
1789
+ "alter table test.test_autobucket_dynamic_partition set ('dynamic_partition.end' = '3')" ;
1790
+ ExceptionChecker .expectThrowsNoException (() -> alterTable (alterStmt2 ));
1791
+ Env .getCurrentEnv ().getDynamicPartitionScheduler ().executeDynamicPartition (tempDynamicPartitionTableInfo , false );
1792
+
1793
+ partitions = Lists .newArrayList (table .getAllPartitions ());
1794
+ partitions .sort (Comparator .comparing (Partition ::getId ));
1795
+ Assert .assertEquals (54 , partitions .size ());
1796
+ Assert .assertTrue (partitions .get (partitions .size () - 1 ).getDistributionInfo ().getBucketNum () > 40 );
1764
1797
}
1765
1798
}
0 commit comments