Skip to content

Commit 115ad1a

Browse files
committed
test: update sqlness
Signed-off-by: WenyXu <wenymedia@gmail.com>
1 parent 0172452 commit 115ad1a

File tree

2 files changed

+134
-8
lines changed

2 files changed

+134
-8
lines changed

tests/cases/standalone/common/alter/repartition_error.result

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Test repartition error cases
1+
-- Test split partition and merge partition error cases
22
-- Setup: Create a physical table with partitions
33
CREATE TABLE repartition_test_table(
44
device_id INT,
@@ -30,27 +30,55 @@ CREATE TABLE logical_metric_table(
3030
Affected Rows: 0
3131

3232
-- Test 0: Logical table cannot be repartitioned
33+
-- Test 0.1: REPARTITION ... INTO
3334
ALTER TABLE logical_metric_table REPARTITION (
34-
device_id < '100'
35+
device_id < 100
36+
) INTO (
37+
device_id < 50,
38+
device_id >= 50 AND device_id < 100
39+
);
40+
41+
Error: 1001(Unsupported), Not supported: REPARTITION on logical tables
42+
43+
-- Test 0.2: SPLIT PARTITION ... INTO
44+
ALTER TABLE logical_metric_table SPLIT PARTITION (
45+
device_id < 100
3546
) INTO (
36-
device_id < '50',
37-
device_id >= '50' AND device_id < '100'
47+
device_id < 50,
48+
device_id >= 50 AND device_id < 100
3849
);
3950

4051
Error: 1001(Unsupported), Not supported: REPARTITION on logical tables
4152

53+
-- Test 0.3: MERGE PARTITION
4254
-- Test 1: New partition rule contains non-partition column (ts is not a partition column)
55+
-- Test 1.1: REPARTITION ... INTO
56+
ALTER TABLE logical_metric_table MERGE PARTITION (
57+
device_id < 100,
58+
device_id >= 100 AND device_id < 200
59+
)
4360
ALTER TABLE repartition_test_table REPARTITION (
4461
device_id < 100
4562
) INTO (
4663
device_id < 50,
4764
device_id >= 50 AND device_id < 100 AND ts < 1000
4865
);
4966

67+
Error: 1001(Unsupported), SQL statement is not supported, keyword: ALTER
68+
69+
-- Test 1.2: SPLIT PARTITION ... INTO
70+
ALTER TABLE repartition_test_table SPLIT PARTITION (
71+
device_id < 100
72+
) INTO (
73+
device_id < 50,
74+
device_id >= 50 AND device_id < 100 AND ts < 1000
75+
);
76+
5077
Error: 1004(InvalidArguments), Cannot find column by name: ts
5178

5279
-- Test 2: From partition expr does not exist in existing partition exprs
5380
-- device_id < 50 is not in the existing partitions (which are < 100, >= 100 AND < 200, >= 200)
81+
-- Test 2.1: REPARTITION ... INTO
5482
ALTER TABLE repartition_test_table REPARTITION (
5583
device_id < 50
5684
) INTO (
@@ -60,12 +88,31 @@ ALTER TABLE repartition_test_table REPARTITION (
6088

6189
Error: 1004(InvalidArguments), Invalid partition rule: partition expression 'device_id < 50' does not exist in table greptime.public.repartition_test_table
6290

91+
-- Test 2.2: SPLIT PARTITION ... INTO
92+
ALTER TABLE repartition_test_table SPLIT PARTITION (
93+
device_id < 50
94+
) INTO (
95+
device_id < 25,
96+
device_id >= 25 AND device_id < 50
97+
);
98+
99+
Error: 1004(InvalidArguments), Invalid partition rule: partition expression 'device_id < 50' does not exist in table greptime.public.repartition_test_table
100+
101+
-- Test 2.3: MERGE PARTITION (similar error - partition expr does not exist)
102+
ALTER TABLE repartition_test_table MERGE PARTITION (
103+
device_id < 50,
104+
device_id >= 50 AND device_id < 75
105+
);
106+
107+
Error: 1004(InvalidArguments), Invalid partition rule: partition expression 'device_id < 50' does not exist in table greptime.public.repartition_test_table
108+
63109
-- Test 3: New partition rule is incomplete (cannot pass checker)
64110
-- This creates a gap: device_id < 50 and device_id >= 100, missing [50, 100)
65111
-- The existing partitions are: device_id < 100, device_id >= 100 AND device_id < 200, device_id >= 200
66112
-- After removing device_id < 100 and adding device_id < 50 and device_id >= 100, we get:
67113
-- device_id < 50, device_id >= 100 AND device_id < 200, device_id >= 200
68114
-- This leaves a gap [50, 100)
115+
-- Test 3.1: REPARTITION ... INTO
69116
ALTER TABLE repartition_test_table REPARTITION (
70117
device_id < 100
71118
) INTO (
@@ -75,11 +122,22 @@ ALTER TABLE repartition_test_table REPARTITION (
75122

76123
Error: 1004(InvalidArguments), Checkpoint `device_id=50` is not covered
77124

125+
-- Test 3.2: SPLIT PARTITION ... INTO
126+
ALTER TABLE repartition_test_table SPLIT PARTITION (
127+
device_id < 100
128+
) INTO (
129+
device_id < 50,
130+
device_id >= 100
131+
);
132+
133+
Error: 1004(InvalidArguments), Checkpoint `device_id=50` is not covered
134+
78135
-- Test 4: New partition rule has overlapping partitions
79136
-- This creates overlapping ranges: device_id < 100 and device_id >= 50 AND device_id < 150
80137
-- After removing device_id < 100, we have: device_id >= 100 AND device_id < 200, device_id >= 200
81138
-- Adding the new ones: device_id < 100, device_id >= 50 AND device_id < 150
82139
-- This overlaps: [0, 100) and [50, 150) overlap in [50, 100)
140+
-- Test 4.1: REPARTITION ... INTO
83141
ALTER TABLE repartition_test_table REPARTITION (
84142
device_id < 100
85143
) INTO (
@@ -89,6 +147,16 @@ ALTER TABLE repartition_test_table REPARTITION (
89147

90148
Error: 1004(InvalidArguments), Checkpoint `device_id=50` is overlapped
91149

150+
-- Test 4.2: SPLIT PARTITION ... INTO
151+
ALTER TABLE repartition_test_table SPLIT PARTITION (
152+
device_id < 100
153+
) INTO (
154+
device_id < 100,
155+
device_id >= 50 AND device_id < 150
156+
);
157+
158+
Error: 1004(InvalidArguments), Checkpoint `device_id=50` is overlapped
159+
92160
-- Cleanup
93161
DROP TABLE repartition_test_table;
94162

tests/cases/standalone/common/alter/repartition_error.sql

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Test repartition error cases
1+
-- Test split partition and merge partition error cases
22

33
-- Setup: Create a physical table with partitions
44
CREATE TABLE repartition_test_table(
@@ -25,55 +25,113 @@ CREATE TABLE logical_metric_table(
2525
) ENGINE = metric WITH ("on_physical_table" = "physical_metric_table");
2626

2727
-- Test 0: Logical table cannot be repartitioned
28+
-- Test 0.1: REPARTITION ... INTO
2829
ALTER TABLE logical_metric_table REPARTITION (
29-
device_id < '100'
30+
device_id < 100
31+
) INTO (
32+
device_id < 50,
33+
device_id >= 50 AND device_id < 100
34+
);
35+
36+
-- Test 0.2: SPLIT PARTITION ... INTO
37+
ALTER TABLE logical_metric_table SPLIT PARTITION (
38+
device_id < 100
3039
) INTO (
31-
device_id < '50',
32-
device_id >= '50' AND device_id < '100'
40+
device_id < 50,
41+
device_id >= 50 AND device_id < 100
3342
);
3443

44+
-- Test 0.3: MERGE PARTITION
45+
ALTER TABLE logical_metric_table MERGE PARTITION (
46+
device_id < 100,
47+
device_id >= 100 AND device_id < 200
48+
)
49+
3550
-- Test 1: New partition rule contains non-partition column (ts is not a partition column)
51+
-- Test 1.1: REPARTITION ... INTO
3652
ALTER TABLE repartition_test_table REPARTITION (
3753
device_id < 100
3854
) INTO (
3955
device_id < 50,
4056
device_id >= 50 AND device_id < 100 AND ts < 1000
4157
);
4258

59+
-- Test 1.2: SPLIT PARTITION ... INTO
60+
ALTER TABLE repartition_test_table SPLIT PARTITION (
61+
device_id < 100
62+
) INTO (
63+
device_id < 50,
64+
device_id >= 50 AND device_id < 100 AND ts < 1000
65+
);
66+
67+
4368
-- Test 2: From partition expr does not exist in existing partition exprs
4469
-- device_id < 50 is not in the existing partitions (which are < 100, >= 100 AND < 200, >= 200)
70+
-- Test 2.1: REPARTITION ... INTO
4571
ALTER TABLE repartition_test_table REPARTITION (
4672
device_id < 50
4773
) INTO (
4874
device_id < 25,
4975
device_id >= 25 AND device_id < 50
5076
);
5177

78+
-- Test 2.2: SPLIT PARTITION ... INTO
79+
ALTER TABLE repartition_test_table SPLIT PARTITION (
80+
device_id < 50
81+
) INTO (
82+
device_id < 25,
83+
device_id >= 25 AND device_id < 50
84+
);
85+
86+
-- Test 2.3: MERGE PARTITION (similar error - partition expr does not exist)
87+
ALTER TABLE repartition_test_table MERGE PARTITION (
88+
device_id < 50,
89+
device_id >= 50 AND device_id < 75
90+
);
91+
5292
-- Test 3: New partition rule is incomplete (cannot pass checker)
5393
-- This creates a gap: device_id < 50 and device_id >= 100, missing [50, 100)
5494
-- The existing partitions are: device_id < 100, device_id >= 100 AND device_id < 200, device_id >= 200
5595
-- After removing device_id < 100 and adding device_id < 50 and device_id >= 100, we get:
5696
-- device_id < 50, device_id >= 100 AND device_id < 200, device_id >= 200
5797
-- This leaves a gap [50, 100)
98+
-- Test 3.1: REPARTITION ... INTO
5899
ALTER TABLE repartition_test_table REPARTITION (
59100
device_id < 100
60101
) INTO (
61102
device_id < 50,
62103
device_id >= 100
63104
);
64105

106+
-- Test 3.2: SPLIT PARTITION ... INTO
107+
ALTER TABLE repartition_test_table SPLIT PARTITION (
108+
device_id < 100
109+
) INTO (
110+
device_id < 50,
111+
device_id >= 100
112+
);
113+
65114
-- Test 4: New partition rule has overlapping partitions
66115
-- This creates overlapping ranges: device_id < 100 and device_id >= 50 AND device_id < 150
67116
-- After removing device_id < 100, we have: device_id >= 100 AND device_id < 200, device_id >= 200
68117
-- Adding the new ones: device_id < 100, device_id >= 50 AND device_id < 150
69118
-- This overlaps: [0, 100) and [50, 150) overlap in [50, 100)
119+
-- Test 4.1: REPARTITION ... INTO
70120
ALTER TABLE repartition_test_table REPARTITION (
71121
device_id < 100
72122
) INTO (
73123
device_id < 100,
74124
device_id >= 50 AND device_id < 150
75125
);
76126

127+
-- Test 4.2: SPLIT PARTITION ... INTO
128+
ALTER TABLE repartition_test_table SPLIT PARTITION (
129+
device_id < 100
130+
) INTO (
131+
device_id < 100,
132+
device_id >= 50 AND device_id < 150
133+
);
134+
77135
-- Cleanup
78136
DROP TABLE repartition_test_table;
79137
DROP TABLE logical_metric_table;

0 commit comments

Comments
 (0)