mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-15 04:20:39 +00:00
* feat: support alter from primary_key to flat Signed-off-by: evenyag <realevenyag@gmail.com> * chore: alter flat to primary_key Signed-off-by: evenyag <realevenyag@gmail.com> * feat: change default_experimental_flat_format to true Signed-off-by: evenyag <realevenyag@gmail.com> * feat: compute channel size from splitted batch size Signed-off-by: evenyag <realevenyag@gmail.com> * test: add tests for split and channel size Signed-off-by: evenyag <realevenyag@gmail.com> * fix: always set sst_format from manifest on region open sanitize_region_options did not set options.sst_format when the default (PrimaryKey) matched the manifest value, leaving it as None after reopen. This caused the alter format change to appear lost. Signed-off-by: evenyag <realevenyag@gmail.com> * test: fix tests Signed-off-by: evenyag <realevenyag@gmail.com> * test: show create table after alteration Signed-off-by: evenyag <realevenyag@gmail.com> * refactor!: rename default_experimental_flat_format to default_flat_format The flat format is no longer experimental. Remove "experimental" from the config field name, doc comments, and all references. Signed-off-by: evenyag <realevenyag@gmail.com> * chore: fix clippy Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com>
103 lines
2.8 KiB
SQL
103 lines
2.8 KiB
SQL
CREATE TABLE test_alt_format(h INTEGER, i INTEGER DEFAULT 0, j TIMESTAMP TIME INDEX, PRIMARY KEY (h)) WITH ('sst_format' = 'primary_key');
|
|
|
|
ALTER TABLE test_alt_format SET 'sst_format' = 'primary_key';
|
|
|
|
INSERT INTO test_alt_format (h, j) VALUES (10, 0);
|
|
|
|
ALTER TABLE test_alt_format ADD COLUMN k INTEGER;
|
|
|
|
INSERT INTO test_alt_format (h, j) VALUES (11, 1);
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT * FROM test_alt_format;
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT i, h FROM test_alt_format;
|
|
|
|
ALTER TABLE test_alt_format SET 'sst_format' = 'flat';
|
|
|
|
SHOW CREATE TABLE test_alt_format;
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT * FROM test_alt_format;
|
|
|
|
INSERT INTO test_alt_format (h, j) VALUES (12, 2);
|
|
|
|
INSERT INTO test_alt_format (h, j, i, k) VALUES (13, 3, 23, 33);
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT * FROM test_alt_format;
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT i, h FROM test_alt_format;
|
|
|
|
ADMIN flush_table('test_alt_format');
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT * FROM test_alt_format;
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT i, h FROM test_alt_format;
|
|
|
|
-- allow to change from flat to primary_key
|
|
ALTER TABLE test_alt_format SET 'sst_format' = 'primary_key';
|
|
|
|
SHOW CREATE TABLE test_alt_format;
|
|
|
|
INSERT INTO test_alt_format (h, j, i) VALUES (14, 4, 34);
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT * FROM test_alt_format;
|
|
|
|
ADMIN flush_table('test_alt_format');
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
SELECT * FROM test_alt_format;
|
|
|
|
DROP TABLE test_alt_format;
|
|
|
|
CREATE TABLE alt_format_phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "", "sst_format" = "primary_key");
|
|
|
|
CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "alt_format_phy");
|
|
|
|
INSERT INTO t1 (ts, val, host) VALUES
|
|
('2022-01-01 00:00:00', 1.23, 'example.com'),
|
|
('2022-01-01 00:00:00', 1.23, 'hello.com'),
|
|
('2022-01-02 00:00:00', 4.56, 'example.com');
|
|
|
|
ALTER TABLE alt_format_phy SET 'sst_format' = 'primary_key';
|
|
|
|
ALTER TABLE t1 SET 'sst_format' = 'primary_key';
|
|
|
|
ALTER TABLE t1 ADD COLUMN k STRING PRIMARY KEY;
|
|
|
|
SELECT * FROM t1 ORDER BY ts ASC;
|
|
|
|
ALTER TABLE alt_format_phy SET 'sst_format' = 'flat';
|
|
|
|
SHOW CREATE TABLE alt_format_phy;
|
|
|
|
SELECT * FROM t1 ORDER BY ts ASC;
|
|
|
|
SELECT host, ts, val FROM t1 where host = 'example.com' ORDER BY ts ASC;
|
|
|
|
INSERT INTO t1 (ts, val, host) VALUES
|
|
('2022-01-01 00:00:01', 3.0, 'example.com'),
|
|
('2022-01-01 00:00:01', 4.0, 'hello.com');
|
|
|
|
SELECT host, ts, val FROM t1 where host = 'example.com' ORDER BY ts ASC;
|
|
|
|
-- allow to change from flat to primary_key
|
|
ALTER TABLE alt_format_phy SET 'sst_format' = 'primary_key';
|
|
|
|
SHOW CREATE TABLE alt_format_phy;
|
|
|
|
INSERT INTO t1 (ts, val, host) VALUES
|
|
('2022-01-01 00:00:02', 5.0, 'example.com');
|
|
|
|
SELECT host, ts, val FROM t1 where host = 'example.com' ORDER BY ts ASC;
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP TABLE alt_format_phy;
|