Files
greptimedb/tests/cases/standalone/common/create/create_database_opts.result
AntiTopQuark cea578244c fix(compaction): unify behavior of database compaction options with TTL (#7402)
* fix: fix dynamic compactiom option,unify behavior of database compaction options with TTL option

Signed-off-by: AntiTopQuark <AntiTopQuark1350@outlook.com>

* fix unit test

Signed-off-by: AntiTopQuark <AntiTopQuark1350@outlook.com>

* add debug log

Signed-off-by: AntiTopQuark <AntiTopQuark1350@outlook.com>

---------

Signed-off-by: AntiTopQuark <AntiTopQuark1350@outlook.com>
2025-12-25 02:34:42 +00:00

352 lines
12 KiB
Plaintext

CREATE DATABASE mydb WITH (ttl = '1h');
Affected Rows: 1
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| greptime_private |
| information_schema |
| mydb |
| public |
+--------------------+
SHOW FULL DATABASES;
+--------------------+------------+
| Database | Options |
+--------------------+------------+
| greptime_private | |
| information_schema | |
| mydb | 'ttl'='1h' |
| | |
| public | |
+--------------------+------------+
SHOW CREATE DATABASE mydb;
+----------+------------------------------------+
| Database | Create Database |
+----------+------------------------------------+
| mydb | CREATE DATABASE IF NOT EXISTS mydb |
| | WITH( |
| | ttl = '1h' |
| | ) |
+----------+------------------------------------+
USE mydb;
Affected Rows: 0
CREATE TABLE test(host STRING, cpu DOUBLE, ts TIMESTAMP TIME INDEX);
Affected Rows: 0
SHOW CREATE TABLE test;
+-------+-------------------------------------+
| Table | Create Table |
+-------+-------------------------------------+
| test | CREATE TABLE IF NOT EXISTS "test" ( |
| | "host" STRING NULL, |
| | "cpu" DOUBLE NULL, |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | WITH( |
| | ttl = '1h' |
| | ) |
+-------+-------------------------------------+
USE public;
Affected Rows: 0
DROP DATABASE mydb;
Affected Rows: 0
---test more options----
CREATE DATABASE mydb WITH (
ttl = '1h',
'memtable.type'='partition_tree',
'append_mode'='false',
'merge_mode'='last_non_null',
'compaction.type' = 'twcs',
'compaction.twcs.time_window' = '1h',
'skip_wal'='true');
Affected Rows: 1
use mydb;
Affected Rows: 0
SHOW FULL DATABASES;
+--------------------+------------------------------------+
| Database | Options |
+--------------------+------------------------------------+
| greptime_private | |
| information_schema | |
| mydb | 'ttl'='1h' |
| | 'append_mode'='false' |
| | 'compaction.twcs.time_window'='1h' |
| | 'compaction.type'='twcs' |
| | 'memtable.type'='partition_tree' |
| | 'merge_mode'='last_non_null' |
| | 'skip_wal'='true' |
| | |
| public | |
+--------------------+------------------------------------+
CREATE TABLE test1(host STRING, cpu DOUBLE, ts TIMESTAMP TIME INDEX);
Affected Rows: 0
SHOW CREATE TABLE test1;
+-------+---------------------------------------+
| Table | Create Table |
+-------+---------------------------------------+
| test1 | CREATE TABLE IF NOT EXISTS "test1" ( |
| | "host" STRING NULL, |
| | "cpu" DOUBLE NULL, |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | WITH( |
| | append_mode = 'false', |
| | 'memtable.type' = 'partition_tree', |
| | merge_mode = 'last_non_null', |
| | skip_wal = 'true', |
| | ttl = '1h' |
| | ) |
+-------+---------------------------------------+
CREATE TABLE test2(host STRING, cpu DOUBLE, ts TIMESTAMP TIME INDEX) WITH (
'append_mode'='true',
'merge_mode'='',
'skip_wal'='false');
Affected Rows: 0
SHOW CREATE TABLE test2;
+-------+---------------------------------------+
| Table | Create Table |
+-------+---------------------------------------+
| test2 | CREATE TABLE IF NOT EXISTS "test2" ( |
| | "host" STRING NULL, |
| | "cpu" DOUBLE NULL, |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | WITH( |
| | append_mode = 'true', |
| | 'memtable.type' = 'partition_tree', |
| | merge_mode = '', |
| | skip_wal = 'false', |
| | ttl = '1h' |
| | ) |
+-------+---------------------------------------+
INSERT INTO test2 VALUES('host1', 1.0, '2023-10-01 00:00:00');
Affected Rows: 1
SELECT * FROM test2;
+-------+-----+---------------------+
| host | cpu | ts |
+-------+-----+---------------------+
| host1 | 1.0 | 2023-10-01T00:00:00 |
+-------+-----+---------------------+
USE public;
Affected Rows: 0
DROP DATABASE mydb;
Affected Rows: 0
--- test compaction options----
CREATE DATABASE test_compaction_opt;
Affected Rows: 1
USE test_compaction_opt;
Affected Rows: 0
SHOW CREATE DATABASE test_compaction_opt;
+---------------------+---------------------------------------------------+
| Database | Create Database |
+---------------------+---------------------------------------------------+
| test_compaction_opt | CREATE DATABASE IF NOT EXISTS test_compaction_opt |
+---------------------+---------------------------------------------------+
CREATE TABLE test_table(ts TIMESTAMP TIME INDEX, val INT);
Affected Rows: 0
SHOW CREATE TABLE test_table;
+------------+-------------------------------------------+
| Table | Create Table |
+------------+-------------------------------------------+
| test_table | CREATE TABLE IF NOT EXISTS "test_table" ( |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | "val" INT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | |
+------------+-------------------------------------------+
ALTER DATABASE test_compaction_opt SET 'compaction.type' = 'twcs';
Affected Rows: 0
ALTER DATABASE test_compaction_opt SET 'compaction.twcs.time_window' = '2h';
Affected Rows: 0
SHOW CREATE DATABASE test_compaction_opt;
+---------------------+---------------------------------------------------+
| Database | Create Database |
+---------------------+---------------------------------------------------+
| test_compaction_opt | CREATE DATABASE IF NOT EXISTS test_compaction_opt |
| | WITH( |
| | 'compaction.twcs.time_window' = '2h', |
| | 'compaction.type' = 'twcs' |
| | ) |
+---------------------+---------------------------------------------------+
SHOW CREATE TABLE test_table;
+------------+-------------------------------------------+
| Table | Create Table |
+------------+-------------------------------------------+
| test_table | CREATE TABLE IF NOT EXISTS "test_table" ( |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | "val" INT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | |
+------------+-------------------------------------------+
CREATE TABLE test_table2(ts TIMESTAMP TIME INDEX, val INT);
Affected Rows: 0
SHOW CREATE TABLE test_table2;
+-------------+--------------------------------------------+
| Table | Create Table |
+-------------+--------------------------------------------+
| test_table2 | CREATE TABLE IF NOT EXISTS "test_table2" ( |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | "val" INT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | |
+-------------+--------------------------------------------+
USE public;
Affected Rows: 0
DROP DATABASE test_compaction_opt;
Affected Rows: 0
CREATE DATABASE test_compaction_opt2;
Affected Rows: 1
USE test_compaction_opt2;
Affected Rows: 0
CREATE TABLE test_table(ts TIMESTAMP TIME INDEX, v INT) WITH ('compaction.type'='twcs','compaction.twcs.time_window'='1h');
Affected Rows: 0
SHOW CREATE TABLE test_table;
+------------+-------------------------------------------+
| Table | Create Table |
+------------+-------------------------------------------+
| test_table | CREATE TABLE IF NOT EXISTS "test_table" ( |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | "v" INT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | WITH( |
| | 'compaction.override' = 'true', |
| | 'compaction.twcs.time_window' = '1h', |
| | 'compaction.type' = 'twcs' |
| | ) |
+------------+-------------------------------------------+
ALTER DATABASE test_compaction_opt2 SET 'compaction.twcs.time_window' = '3h';
Affected Rows: 0
SHOW CREATE TABLE test_table;
+------------+-------------------------------------------+
| Table | Create Table |
+------------+-------------------------------------------+
| test_table | CREATE TABLE IF NOT EXISTS "test_table" ( |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | "v" INT NULL, |
| | TIME INDEX ("ts") |
| | ) |
| | |
| | ENGINE=mito |
| | WITH( |
| | 'compaction.override' = 'true', |
| | 'compaction.twcs.time_window' = '1h', |
| | 'compaction.type' = 'twcs' |
| | ) |
+------------+-------------------------------------------+
USE public;
Affected Rows: 0
DROP DATABASE test_compaction_opt2;
Affected Rows: 0
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| greptime_private |
| information_schema |
| public |
+--------------------+