Skip to content

Commit 502a140

Browse files
committed
test: update sqlness
Signed-off-by: WenyXu <[email protected]>
1 parent 0172452 commit 502a140

File tree

2 files changed

+118
-8
lines changed

2 files changed

+118
-8
lines changed

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

Lines changed: 63 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,
@@ -31,10 +31,26 @@ Affected Rows: 0
3131

3232
-- Test 0: Logical table cannot be repartitioned
3333
ALTER 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

4056
Error: 1001(Unsupported), Not supported: REPARTITION on logical tables
@@ -49,6 +65,15 @@ ALTER TABLE repartition_test_table REPARTITION (
4965

5066
Error: 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)
5479
ALTER TABLE repartition_test_table REPARTITION (
@@ -60,6 +85,22 @@ ALTER TABLE repartition_test_table REPARTITION (
6085

6186
Error: 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

76117
Error: 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

90140
Error: 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
93152
DROP TABLE repartition_test_table;
94153

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

Lines changed: 55 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,106 @@ 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+
2829
ALTER TABLE logical_metric_table REPARTITION (
29-
device_id < '100'
30+
device_id < 100
3031
) INTO (
31-
device_id < '50',
32-
device_id >= '50' AND device_id < '100'
32+
device_id < 50,
33+
device_id >= 50 AND device_id < 100
34+
);
35+
36+
ALTER TABLE logical_metric_table SPLIT PARTITION (
37+
device_id < 100
38+
) INTO (
39+
device_id < 50,
40+
device_id >= 50 AND device_id < 100
41+
);
42+
43+
ALTER TABLE logical_metric_table MERGE PARTITION (
44+
device_id < 100,
45+
device_id >= 100 AND device_id < 200
3346
);
3447

3548
-- Test 1: New partition rule contains non-partition column (ts is not a partition column)
49+
3650
ALTER TABLE repartition_test_table REPARTITION (
3751
device_id < 100
3852
) INTO (
3953
device_id < 50,
4054
device_id >= 50 AND device_id < 100 AND ts < 1000
4155
);
4256

57+
ALTER TABLE repartition_test_table SPLIT PARTITION (
58+
device_id < 100
59+
) INTO (
60+
device_id < 50,
61+
device_id >= 50 AND device_id < 100 AND ts < 1000
62+
);
63+
64+
4365
-- Test 2: From partition expr does not exist in existing partition exprs
4466
-- device_id < 50 is not in the existing partitions (which are < 100, >= 100 AND < 200, >= 200)
67+
4568
ALTER TABLE repartition_test_table REPARTITION (
4669
device_id < 50
4770
) INTO (
4871
device_id < 25,
4972
device_id >= 25 AND device_id < 50
5073
);
5174

75+
ALTER TABLE repartition_test_table SPLIT PARTITION (
76+
device_id < 50
77+
) INTO (
78+
device_id < 25,
79+
device_id >= 25 AND device_id < 50
80+
);
81+
82+
ALTER TABLE repartition_test_table MERGE PARTITION (
83+
device_id < 50,
84+
device_id >= 50 AND device_id < 75
85+
);
86+
5287
-- Test 3: New partition rule is incomplete (cannot pass checker)
5388
-- This creates a gap: device_id < 50 and device_id >= 100, missing [50, 100)
5489
-- The existing partitions are: device_id < 100, device_id >= 100 AND device_id < 200, device_id >= 200
5590
-- After removing device_id < 100 and adding device_id < 50 and device_id >= 100, we get:
5691
-- device_id < 50, device_id >= 100 AND device_id < 200, device_id >= 200
5792
-- This leaves a gap [50, 100)
93+
5894
ALTER TABLE repartition_test_table REPARTITION (
5995
device_id < 100
6096
) INTO (
6197
device_id < 50,
6298
device_id >= 100
6399
);
64100

101+
ALTER TABLE repartition_test_table SPLIT PARTITION (
102+
device_id < 100
103+
) INTO (
104+
device_id < 50,
105+
device_id >= 100
106+
);
107+
65108
-- Test 4: New partition rule has overlapping partitions
66109
-- This creates overlapping ranges: device_id < 100 and device_id >= 50 AND device_id < 150
67110
-- After removing device_id < 100, we have: device_id >= 100 AND device_id < 200, device_id >= 200
68111
-- Adding the new ones: device_id < 100, device_id >= 50 AND device_id < 150
69112
-- This overlaps: [0, 100) and [50, 150) overlap in [50, 100)
113+
70114
ALTER TABLE repartition_test_table REPARTITION (
71115
device_id < 100
72116
) INTO (
73117
device_id < 100,
74118
device_id >= 50 AND device_id < 150
75119
);
76120

121+
ALTER TABLE repartition_test_table SPLIT PARTITION (
122+
device_id < 100
123+
) INTO (
124+
device_id < 100,
125+
device_id >= 50 AND device_id < 150
126+
);
127+
77128
-- Cleanup
78129
DROP TABLE repartition_test_table;
79130
DROP TABLE logical_metric_table;

0 commit comments

Comments
 (0)