1- -- Test repartition error cases
1+ -- Test split partition and merge partition error cases
22-- Setup: Create a physical table with partitions
33CREATE TABLE repartition_test_table(
44 device_id INT,
@@ -31,10 +31,26 @@ Affected Rows: 0
3131
3232-- Test 0: Logical table cannot be repartitioned
3333ALTER TABLE logical_metric_table REPARTITION (
34- device_id < ' 100'
34+ device_id < 100
3535) INTO (
36- device_id < '50',
37- device_id >= '50' AND device_id < '100'
36+ device_id < 50,
37+ device_id >= 50 AND device_id < 100
38+ );
39+
40+ Error: 1001(Unsupported), Not supported: REPARTITION on logical tables
41+
42+ ALTER TABLE logical_metric_table SPLIT PARTITION (
43+ device_id < 100
44+ ) INTO (
45+ device_id < 50,
46+ device_id >= 50 AND device_id < 100
47+ );
48+
49+ Error: 1001(Unsupported), Not supported: REPARTITION on logical tables
50+
51+ ALTER TABLE logical_metric_table MERGE PARTITION (
52+ device_id < 100,
53+ device_id >= 100 AND device_id < 200
3854);
3955
4056Error: 1001(Unsupported), Not supported: REPARTITION on logical tables
@@ -49,6 +65,15 @@ ALTER TABLE repartition_test_table REPARTITION (
4965
5066Error: 1004(InvalidArguments), Cannot find column by name: ts
5167
68+ ALTER TABLE repartition_test_table SPLIT PARTITION (
69+ device_id < 100
70+ ) INTO (
71+ device_id < 50,
72+ device_id >= 50 AND device_id < 100 AND ts < 1000
73+ );
74+
75+ Error: 1004(InvalidArguments), Cannot find column by name: ts
76+
5277-- Test 2: From partition expr does not exist in existing partition exprs
5378-- device_id < 50 is not in the existing partitions (which are < 100, >= 100 AND < 200, >= 200)
5479ALTER TABLE repartition_test_table REPARTITION (
@@ -60,6 +85,22 @@ ALTER TABLE repartition_test_table REPARTITION (
6085
6186Error: 1004(InvalidArguments), Invalid partition rule: partition expression 'device_id < 50' does not exist in table greptime.public.repartition_test_table
6287
88+ ALTER TABLE repartition_test_table SPLIT PARTITION (
89+ device_id < 50
90+ ) INTO (
91+ device_id < 25,
92+ device_id >= 25 AND device_id < 50
93+ );
94+
95+ Error: 1004(InvalidArguments), Invalid partition rule: partition expression 'device_id < 50' does not exist in table greptime.public.repartition_test_table
96+
97+ ALTER TABLE repartition_test_table MERGE PARTITION (
98+ device_id < 50,
99+ device_id >= 50 AND device_id < 75
100+ );
101+
102+ Error: 1004(InvalidArguments), Invalid partition rule: partition expression 'device_id < 50' does not exist in table greptime.public.repartition_test_table
103+
63104-- Test 3: New partition rule is incomplete (cannot pass checker)
64105-- This creates a gap: device_id < 50 and device_id >= 100, missing [50, 100)
65106-- The existing partitions are: device_id < 100, device_id >= 100 AND device_id < 200, device_id >= 200
@@ -75,6 +116,15 @@ ALTER TABLE repartition_test_table REPARTITION (
75116
76117Error: 1004(InvalidArguments), Checkpoint `device_id=50` is not covered
77118
119+ ALTER TABLE repartition_test_table SPLIT PARTITION (
120+ device_id < 100
121+ ) INTO (
122+ device_id < 50,
123+ device_id >= 100
124+ );
125+
126+ Error: 1004(InvalidArguments), Checkpoint `device_id=50` is not covered
127+
78128-- Test 4: New partition rule has overlapping partitions
79129-- This creates overlapping ranges: device_id < 100 and device_id >= 50 AND device_id < 150
80130-- After removing device_id < 100, we have: device_id >= 100 AND device_id < 200, device_id >= 200
@@ -89,6 +139,15 @@ ALTER TABLE repartition_test_table REPARTITION (
89139
90140Error: 1004(InvalidArguments), Checkpoint `device_id=50` is overlapped
91141
142+ ALTER TABLE repartition_test_table SPLIT PARTITION (
143+ device_id < 100
144+ ) INTO (
145+ device_id < 100,
146+ device_id >= 50 AND device_id < 150
147+ );
148+
149+ Error: 1004(InvalidArguments), Checkpoint `device_id=50` is overlapped
150+
92151-- Cleanup
93152DROP TABLE repartition_test_table;
94153
0 commit comments