Files
greptimedb/tests/cases/distributed/repartition/repartition.sql
Weny Xu 7039e54835 fix: require metasrv GC for repartition (#8497)
* fix: require GC for repartition

Signed-off-by: WenyXu <wenymedia@gmail.com>

* test: update sqlness result

Signed-off-by: WenyXu <wenymedia@gmail.com>

* test: enable GC for repartition integration tests

Signed-off-by: WenyXu <wenymedia@gmail.com>

---------

Signed-off-by: WenyXu <wenymedia@gmail.com>
2026-07-14 12:04:03 +00:00

151 lines
3.4 KiB
SQL

CREATE TABLE alter_repartition_table(
device_id INT,
area STRING,
ty STRING,
ts TIMESTAMP TIME INDEX,
PRIMARY KEY(device_id)
) PARTITION ON COLUMNS (device_id, area) (
device_id < 100,
device_id >= 100 AND device_id < 200,
device_id >= 200
);
-- Repartition requires metasrv GC. Verify split requests are rejected when it is disabled.
ALTER TABLE alter_repartition_table REPARTITION (
device_id < 100
) INTO (
device_id < 100 AND area < 'South',
device_id < 100 AND area >= 'South'
);
SHOW CREATE TABLE alter_repartition_table;
-- Repartition requires metasrv GC. Verify split requests are rejected when it is disabled.
ALTER TABLE alter_repartition_table MERGE PARTITION (
device_id < 100,
device_id >= 100 AND device_id < 200,
);
SHOW CREATE TABLE alter_repartition_table;
-- FIXME(weny): Object store is not configured for the test environment,
-- so staging manifest may not be applied in some cases.
-- invalid: empty source clause
ALTER TABLE alter_repartition_table REPARTITION () INTO (
device_id < 100
);
-- invalid: more than one INTO clause
ALTER TABLE alter_repartition_table REPARTITION (
device_id < 100
) INTO (
device_id < 50
), (
device_id >= 50
) INTO (
device_id >= 50
);
DROP TABLE alter_repartition_table;
CREATE TABLE alter_repartition_table_with_options(
device_id INT,
area STRING,
ty STRING,
ts TIMESTAMP TIME INDEX,
PRIMARY KEY(device_id)
) PARTITION ON COLUMNS (device_id, area) (
device_id < 100,
device_id >= 100 AND device_id < 200,
device_id >= 200
);
-- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}) PROC_ID
ALTER TABLE alter_repartition_table_with_options REPARTITION (
device_id < 100
) INTO (
device_id < 100 AND area < 'South',
device_id < 100 AND area >= 'South'
) WITH (
TIMEOUT = '5m',
WAIT = false
);
DROP TABLE alter_repartition_table_with_options;
-- Metric engine repartition test
CREATE TABLE metric_physical_table (
ts TIMESTAMP TIME INDEX,
host STRING,
cpu DOUBLE,
PRIMARY KEY(host)
)
PARTITION ON COLUMNS (host) (
host < 'h1',
host >= 'h1' AND host < 'h2',
host >= 'h2'
)
ENGINE = metric
WITH (
physical_metric_table = "true"
);
CREATE TABLE logical_table_v1 (
ts TIMESTAMP TIME INDEX,
host STRING PRIMARY KEY,
cpu DOUBLE,
)
ENGINE = metric
WITH (
on_physical_table = "metric_physical_table"
);
CREATE TABLE logical_table_v2 (
ts TIMESTAMP TIME INDEX,
host STRING PRIMARY KEY,
cpu DOUBLE,
)
ENGINE = metric
WITH (
on_physical_table = "metric_physical_table"
);
-- Repartition requires metasrv GC. Verify split requests are rejected when it is disabled.
ALTER TABLE metric_physical_table SPLIT PARTITION (
host < 'h1'
) INTO (
host < 'h0',
host >= 'h0' AND host < 'h1'
);
SHOW CREATE TABLE metric_physical_table;
-- Verify select * works and returns empty
SELECT * FROM metric_physical_table;
SELECT * FROM logical_table_v1;
SELECT * FROM logical_table_v2;
-- Repartition requires metasrv GC. Verify split requests are rejected when it is disabled.
ALTER TABLE metric_physical_table MERGE PARTITION (
host < 'h1',
host >= 'h1' AND host < 'h2'
);
SHOW CREATE TABLE metric_physical_table;
-- Verify select * works and returns empty
SELECT * FROM metric_physical_table;
SELECT * FROM logical_table_v1;
SELECT * FROM logical_table_v2;
DROP TABLE logical_table_v1;
DROP TABLE logical_table_v2;
DROP TABLE metric_physical_table;