From 6b587eb0a530c9c51d09a2e13fc203daeb84da81 Mon Sep 17 00:00:00 2001 From: discord9 Date: Thu, 2 Jul 2026 11:13:53 +0800 Subject: [PATCH] test: add recent sqlness compat cases (#8395) * test: add recent sqlness compat cases Signed-off-by: discord9 * test: add more sqlness compat cases Signed-off-by: discord9 --------- Signed-off-by: discord9 --- .../cases/column_default/case.toml | 8 +++ .../cases/column_default/setup.sql | 16 +++++ .../cases/column_default/verify.result | 41 ++++++++++++ .../cases/column_default/verify.sql | 8 +++ .../information_schema_old_table/case.toml | 8 +++ .../information_schema_old_table/setup.sql | 12 ++++ .../verify.result | 34 ++++++++++ .../information_schema_old_table/verify.sql | 13 ++++ .../cases/json2_compat/case.toml | 8 +++ .../cases/json2_compat/setup.sql | 12 ++++ .../cases/json2_compat/verify.result | 52 +++++++++++++++ .../cases/json2_compat/verify.sql | 15 +++++ .../cases/last_row_append_mode/case.toml | 8 +++ .../cases/last_row_append_mode/setup.sql | 18 +++++ .../cases/last_row_append_mode/verify.result | 52 +++++++++++++++ .../cases/last_row_append_mode/verify.sql | 15 +++++ .../cases/last_row_merge/case.toml | 8 +++ .../cases/last_row_merge/setup.sql | 19 ++++++ .../cases/last_row_merge/verify.result | 41 ++++++++++++ .../cases/last_row_merge/verify.sql | 10 +++ .../cases/legacy_json_non_object/case.toml | 8 +++ .../cases/legacy_json_non_object/setup.sql | 15 +++++ .../legacy_json_non_object/verify.result | 60 +++++++++++++++++ .../cases/legacy_json_non_object/verify.sql | 13 ++++ .../cases/prefiltered_read/case.toml | 8 +++ .../cases/prefiltered_read/setup.sql | 17 +++++ .../cases/prefiltered_read/verify.result | 42 ++++++++++++ .../cases/prefiltered_read/verify.sql | 16 +++++ tests/compatibility/cases/table_ttl/case.toml | 8 +++ tests/compatibility/cases/table_ttl/setup.sql | 12 ++++ .../cases/table_ttl/verify.result | 65 +++++++++++++++++++ .../compatibility/cases/table_ttl/verify.sql | 12 ++++ 32 files changed, 674 insertions(+) create mode 100644 tests/compatibility/cases/column_default/case.toml create mode 100644 tests/compatibility/cases/column_default/setup.sql create mode 100644 tests/compatibility/cases/column_default/verify.result create mode 100644 tests/compatibility/cases/column_default/verify.sql create mode 100644 tests/compatibility/cases/information_schema_old_table/case.toml create mode 100644 tests/compatibility/cases/information_schema_old_table/setup.sql create mode 100644 tests/compatibility/cases/information_schema_old_table/verify.result create mode 100644 tests/compatibility/cases/information_schema_old_table/verify.sql create mode 100644 tests/compatibility/cases/json2_compat/case.toml create mode 100644 tests/compatibility/cases/json2_compat/setup.sql create mode 100644 tests/compatibility/cases/json2_compat/verify.result create mode 100644 tests/compatibility/cases/json2_compat/verify.sql create mode 100644 tests/compatibility/cases/last_row_append_mode/case.toml create mode 100644 tests/compatibility/cases/last_row_append_mode/setup.sql create mode 100644 tests/compatibility/cases/last_row_append_mode/verify.result create mode 100644 tests/compatibility/cases/last_row_append_mode/verify.sql create mode 100644 tests/compatibility/cases/last_row_merge/case.toml create mode 100644 tests/compatibility/cases/last_row_merge/setup.sql create mode 100644 tests/compatibility/cases/last_row_merge/verify.result create mode 100644 tests/compatibility/cases/last_row_merge/verify.sql create mode 100644 tests/compatibility/cases/legacy_json_non_object/case.toml create mode 100644 tests/compatibility/cases/legacy_json_non_object/setup.sql create mode 100644 tests/compatibility/cases/legacy_json_non_object/verify.result create mode 100644 tests/compatibility/cases/legacy_json_non_object/verify.sql create mode 100644 tests/compatibility/cases/prefiltered_read/case.toml create mode 100644 tests/compatibility/cases/prefiltered_read/setup.sql create mode 100644 tests/compatibility/cases/prefiltered_read/verify.result create mode 100644 tests/compatibility/cases/prefiltered_read/verify.sql create mode 100644 tests/compatibility/cases/table_ttl/case.toml create mode 100644 tests/compatibility/cases/table_ttl/setup.sql create mode 100644 tests/compatibility/cases/table_ttl/verify.result create mode 100644 tests/compatibility/cases/table_ttl/verify.sql diff --git a/tests/compatibility/cases/column_default/case.toml b/tests/compatibility/cases/column_default/case.toml new file mode 100644 index 0000000000..7b2503e2af --- /dev/null +++ b/tests/compatibility/cases/column_default/case.toml @@ -0,0 +1,8 @@ +name = "column_default" +reason = "Verify column DEFAULT metadata created by old binaries still works for inserts after upgrade." +introduced_by = "PR #8376 follow-up" +topologies = ["distributed"] +from_range = ["*"] +to_range = ["*"] +features = ["table", "default"] +owner = "query" diff --git a/tests/compatibility/cases/column_default/setup.sql b/tests/compatibility/cases/column_default/setup.sql new file mode 100644 index 0000000000..abb7ce0910 --- /dev/null +++ b/tests/compatibility/cases/column_default/setup.sql @@ -0,0 +1,16 @@ +CREATE TABLE t_column_default( + ts TIMESTAMP TIME INDEX, + host STRING PRIMARY KEY, + val INT DEFAULT 42, + msg STRING DEFAULT 'hello', + score DOUBLE DEFAULT 1.5 +); + +INSERT INTO t_column_default (ts, host) VALUES +('2024-02-03 00:00:00+0000', 'host_a'), +('2024-02-03 00:01:00+0000', 'host_b'); + +INSERT INTO t_column_default (ts, host, val, msg, score) VALUES +('2024-02-03 00:02:00+0000', 'host_c', 100, 'override', 9.5); + +ADMIN FLUSH_TABLE('t_column_default'); diff --git a/tests/compatibility/cases/column_default/verify.result b/tests/compatibility/cases/column_default/verify.result new file mode 100644 index 0000000000..732576213b --- /dev/null +++ b/tests/compatibility/cases/column_default/verify.result @@ -0,0 +1,41 @@ +SELECT ts, host, val, msg, score FROM t_column_default ORDER BY ts, host; + ++---------------------+--------+-----+----------+-------+ +| ts | host | val | msg | score | ++---------------------+--------+-----+----------+-------+ +| 2024-02-03T00:00:00 | host_a | 42 | hello | 1.5 | +| 2024-02-03T00:01:00 | host_b | 42 | hello | 1.5 | +| 2024-02-03T00:02:00 | host_c | 100 | override | 9.5 | ++---------------------+--------+-----+----------+-------+ + +INSERT INTO t_column_default (ts, host) VALUES +('2024-02-03 00:03:00+0000', 'host_d'); + +Affected Rows: 1 + +SELECT ts, host, val, msg, score FROM t_column_default WHERE host = 'host_d'; + ++---------------------+--------+-----+-------+-------+ +| ts | host | val | msg | score | ++---------------------+--------+-----+-------+-------+ +| 2024-02-03T00:03:00 | host_d | 42 | hello | 1.5 | ++---------------------+--------+-----+-------+-------+ + +SHOW CREATE TABLE t_column_default; + ++------------------+-------------------------------------------------+ +| Table | Create Table | ++------------------+-------------------------------------------------+ +| t_column_default | CREATE TABLE IF NOT EXISTS "t_column_default" ( | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "host" STRING NULL, | +| | "val" INT NULL DEFAULT 42, | +| | "msg" STRING NULL DEFAULT 'hello', | +| | "score" DOUBLE NULL DEFAULT 1.5, | +| | TIME INDEX ("ts"), | +| | PRIMARY KEY ("host") | +| | ) | +| | | +| | ENGINE=mito | +| | | ++------------------+-------------------------------------------------+ diff --git a/tests/compatibility/cases/column_default/verify.sql b/tests/compatibility/cases/column_default/verify.sql new file mode 100644 index 0000000000..91e1d592de --- /dev/null +++ b/tests/compatibility/cases/column_default/verify.sql @@ -0,0 +1,8 @@ +SELECT ts, host, val, msg, score FROM t_column_default ORDER BY ts, host; + +INSERT INTO t_column_default (ts, host) VALUES +('2024-02-03 00:03:00+0000', 'host_d'); + +SELECT ts, host, val, msg, score FROM t_column_default WHERE host = 'host_d'; + +SHOW CREATE TABLE t_column_default; diff --git a/tests/compatibility/cases/information_schema_old_table/case.toml b/tests/compatibility/cases/information_schema_old_table/case.toml new file mode 100644 index 0000000000..df5cb444bd --- /dev/null +++ b/tests/compatibility/cases/information_schema_old_table/case.toml @@ -0,0 +1,8 @@ +name = "information_schema_old_table" +reason = "Verify current information_schema views expose table and column metadata for tables created by old binaries." +introduced_by = "PR #8210" +topologies = ["distributed"] +from_range = ["*"] +to_range = ["*"] +features = ["information_schema", "table"] +owner = "query" diff --git a/tests/compatibility/cases/information_schema_old_table/setup.sql b/tests/compatibility/cases/information_schema_old_table/setup.sql new file mode 100644 index 0000000000..5d482d4c0e --- /dev/null +++ b/tests/compatibility/cases/information_schema_old_table/setup.sql @@ -0,0 +1,12 @@ +CREATE TABLE t_information_schema_old_table( + ts TIMESTAMP TIME INDEX, + host STRING PRIMARY KEY, + val DOUBLE, + code INT +); + +INSERT INTO t_information_schema_old_table VALUES +('2024-02-09 00:00:00+0000', 'host_a', 1.0, 200), +('2024-02-09 00:01:00+0000', 'host_b', 2.0, 500); + +ADMIN FLUSH_TABLE('t_information_schema_old_table'); diff --git a/tests/compatibility/cases/information_schema_old_table/verify.result b/tests/compatibility/cases/information_schema_old_table/verify.result new file mode 100644 index 0000000000..88bb03355a --- /dev/null +++ b/tests/compatibility/cases/information_schema_old_table/verify.result @@ -0,0 +1,34 @@ +SELECT table_schema, table_name, table_type, engine +FROM information_schema.tables +WHERE table_name = 't_information_schema_old_table' +ORDER BY table_schema; + ++------------------------------+--------------------------------+------------+--------+ +| table_schema | table_name | table_type | engine | ++------------------------------+--------------------------------+------------+--------+ +| information_schema_old_table | t_information_schema_old_table | BASE TABLE | mito | ++------------------------------+--------------------------------+------------+--------+ + +SELECT column_name, data_type, semantic_type +FROM information_schema.columns +WHERE table_name = 't_information_schema_old_table' +ORDER BY table_schema, column_name; + ++-------------+--------------+---------------+ +| column_name | data_type | semantic_type | ++-------------+--------------+---------------+ +| code | int | FIELD | +| host | string | TAG | +| ts | timestamp(3) | TIMESTAMP | +| val | double | FIELD | ++-------------+--------------+---------------+ + +SELECT count(*) +FROM information_schema.table_semantics +WHERE table_name = 't_information_schema_old_table'; + ++----------+ +| count(*) | ++----------+ +| 0 | ++----------+ diff --git a/tests/compatibility/cases/information_schema_old_table/verify.sql b/tests/compatibility/cases/information_schema_old_table/verify.sql new file mode 100644 index 0000000000..556f7a7467 --- /dev/null +++ b/tests/compatibility/cases/information_schema_old_table/verify.sql @@ -0,0 +1,13 @@ +SELECT table_schema, table_name, table_type, engine +FROM information_schema.tables +WHERE table_name = 't_information_schema_old_table' +ORDER BY table_schema; + +SELECT column_name, data_type, semantic_type +FROM information_schema.columns +WHERE table_name = 't_information_schema_old_table' +ORDER BY table_schema, column_name; + +SELECT count(*) +FROM information_schema.table_semantics +WHERE table_name = 't_information_schema_old_table'; diff --git a/tests/compatibility/cases/json2_compat/case.toml b/tests/compatibility/cases/json2_compat/case.toml new file mode 100644 index 0000000000..570c91cdf8 --- /dev/null +++ b/tests/compatibility/cases/json2_compat/case.toml @@ -0,0 +1,8 @@ +name = "json2_compat" +reason = "Verify JSON data written by v1.1.x JSON2 binaries remains readable after later JSON2 read/flush/compaction changes." +introduced_by = "PR #7965" +topologies = ["distributed"] +from_range = [">=v1.1.0"] +to_range = ["*"] +features = ["json", "table"] +owner = "query" diff --git a/tests/compatibility/cases/json2_compat/setup.sql b/tests/compatibility/cases/json2_compat/setup.sql new file mode 100644 index 0000000000..07af84fb13 --- /dev/null +++ b/tests/compatibility/cases/json2_compat/setup.sql @@ -0,0 +1,12 @@ +CREATE TABLE t_json2_compat( + ts TIMESTAMP TIME INDEX, + host STRING PRIMARY KEY, + j JSON +); + +INSERT INTO t_json2_compat VALUES +('2024-02-05 00:00:00+0000', 'host_a', parse_json('{"a": 10, "nested": {"b": "x"}, "flag": true}')), +('2024-02-05 00:01:00+0000', 'host_b', parse_json('{"a": 20, "nested": {"b": "y"}, "flag": false}')), +('2024-02-05 00:02:00+0000', 'host_c', parse_json('{"a": 30, "nested": {"b": "z"}, "flag": true}')); + +ADMIN FLUSH_TABLE('t_json2_compat'); diff --git a/tests/compatibility/cases/json2_compat/verify.result b/tests/compatibility/cases/json2_compat/verify.result new file mode 100644 index 0000000000..2f2044440b --- /dev/null +++ b/tests/compatibility/cases/json2_compat/verify.result @@ -0,0 +1,52 @@ +SELECT host, json_to_string(j) +FROM t_json2_compat +ORDER BY host; + ++--------+------------------------------------------+ +| host | json_to_string(t_json2_compat.j) | ++--------+------------------------------------------+ +| host_a | {"a":10,"flag":true,"nested":{"b":"x"}} | +| host_b | {"a":20,"flag":false,"nested":{"b":"y"}} | +| host_c | {"a":30,"flag":true,"nested":{"b":"z"}} | ++--------+------------------------------------------+ + +SELECT host, json_get_int(j, 'a') AS a +FROM t_json2_compat +WHERE json_get_int(j, 'a') >= 20 +ORDER BY host; + ++--------+----+ +| host | a | ++--------+----+ +| host_b | 20 | +| host_c | 30 | ++--------+----+ + +SELECT host, json_get_string(j, 'nested.b') AS nested_b +FROM t_json2_compat +WHERE json_get_bool(j, 'flag') = true +ORDER BY host; + ++--------+----------+ +| host | nested_b | ++--------+----------+ +| host_a | x | +| host_c | z | ++--------+----------+ + +SHOW CREATE TABLE t_json2_compat; + ++----------------+-----------------------------------------------+ +| Table | Create Table | ++----------------+-----------------------------------------------+ +| t_json2_compat | CREATE TABLE IF NOT EXISTS "t_json2_compat" ( | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "host" STRING NULL, | +| | "j" JSON NULL, | +| | TIME INDEX ("ts"), | +| | PRIMARY KEY ("host") | +| | ) | +| | | +| | ENGINE=mito | +| | | ++----------------+-----------------------------------------------+ diff --git a/tests/compatibility/cases/json2_compat/verify.sql b/tests/compatibility/cases/json2_compat/verify.sql new file mode 100644 index 0000000000..3ade7f924a --- /dev/null +++ b/tests/compatibility/cases/json2_compat/verify.sql @@ -0,0 +1,15 @@ +SELECT host, json_to_string(j) +FROM t_json2_compat +ORDER BY host; + +SELECT host, json_get_int(j, 'a') AS a +FROM t_json2_compat +WHERE json_get_int(j, 'a') >= 20 +ORDER BY host; + +SELECT host, json_get_string(j, 'nested.b') AS nested_b +FROM t_json2_compat +WHERE json_get_bool(j, 'flag') = true +ORDER BY host; + +SHOW CREATE TABLE t_json2_compat; diff --git a/tests/compatibility/cases/last_row_append_mode/case.toml b/tests/compatibility/cases/last_row_append_mode/case.toml new file mode 100644 index 0000000000..3477034030 --- /dev/null +++ b/tests/compatibility/cases/last_row_append_mode/case.toml @@ -0,0 +1,8 @@ +name = "last_row_append_mode" +reason = "Verify a table created with merge_mode='last_row' by old binaries can switch to append_mode after upgrade." +introduced_by = "PR #8065" +topologies = ["distributed"] +from_range = ["*"] +to_range = ["*"] +features = ["table", "merge", "append_mode"] +owner = "storage" diff --git a/tests/compatibility/cases/last_row_append_mode/setup.sql b/tests/compatibility/cases/last_row_append_mode/setup.sql new file mode 100644 index 0000000000..03e9649600 --- /dev/null +++ b/tests/compatibility/cases/last_row_append_mode/setup.sql @@ -0,0 +1,18 @@ +CREATE TABLE t_last_row_append_mode( + host STRING, + ts TIMESTAMP TIME INDEX, + cpu DOUBLE, + PRIMARY KEY(host) +) +ENGINE=mito +WITH('merge_mode'='last_row'); + +INSERT INTO t_last_row_append_mode VALUES +('host1', 0, 1.0), +('host2', 1, 2.0); + +INSERT INTO t_last_row_append_mode VALUES +('host1', 0, 10.0), +('host2', 1, 20.0); + +ADMIN FLUSH_TABLE('t_last_row_append_mode'); diff --git a/tests/compatibility/cases/last_row_append_mode/verify.result b/tests/compatibility/cases/last_row_append_mode/verify.result new file mode 100644 index 0000000000..f5512b893f --- /dev/null +++ b/tests/compatibility/cases/last_row_append_mode/verify.result @@ -0,0 +1,52 @@ +SELECT host, ts, cpu +FROM t_last_row_append_mode +ORDER BY host, ts, cpu; + ++-------+-------------------------+------+ +| host | ts | cpu | ++-------+-------------------------+------+ +| host1 | 1970-01-01T00:00:00 | 10.0 | +| host2 | 1970-01-01T00:00:00.001 | 20.0 | ++-------+-------------------------+------+ + +ALTER TABLE t_last_row_append_mode SET 'append_mode' = 'true'; + +Affected Rows: 0 + +SHOW CREATE TABLE t_last_row_append_mode; + ++------------------------+-------------------------------------------------------+ +| Table | Create Table | ++------------------------+-------------------------------------------------------+ +| t_last_row_append_mode | CREATE TABLE IF NOT EXISTS "t_last_row_append_mode" ( | +| | "host" STRING NULL, | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "cpu" DOUBLE NULL, | +| | TIME INDEX ("ts"), | +| | PRIMARY KEY ("host") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | append_mode = 'true' | +| | ) | ++------------------------+-------------------------------------------------------+ + +INSERT INTO t_last_row_append_mode VALUES +('host1', 0, 100.0), +('host2', 1, 200.0); + +Affected Rows: 2 + +SELECT host, ts, cpu +FROM t_last_row_append_mode +ORDER BY host, ts, cpu; + ++-------+-------------------------+-------+ +| host | ts | cpu | ++-------+-------------------------+-------+ +| host1 | 1970-01-01T00:00:00 | 10.0 | +| host1 | 1970-01-01T00:00:00 | 100.0 | +| host2 | 1970-01-01T00:00:00.001 | 20.0 | +| host2 | 1970-01-01T00:00:00.001 | 200.0 | ++-------+-------------------------+-------+ diff --git a/tests/compatibility/cases/last_row_append_mode/verify.sql b/tests/compatibility/cases/last_row_append_mode/verify.sql new file mode 100644 index 0000000000..498da67071 --- /dev/null +++ b/tests/compatibility/cases/last_row_append_mode/verify.sql @@ -0,0 +1,15 @@ +SELECT host, ts, cpu +FROM t_last_row_append_mode +ORDER BY host, ts, cpu; + +ALTER TABLE t_last_row_append_mode SET 'append_mode' = 'true'; + +SHOW CREATE TABLE t_last_row_append_mode; + +INSERT INTO t_last_row_append_mode VALUES +('host1', 0, 100.0), +('host2', 1, 200.0); + +SELECT host, ts, cpu +FROM t_last_row_append_mode +ORDER BY host, ts, cpu; diff --git a/tests/compatibility/cases/last_row_merge/case.toml b/tests/compatibility/cases/last_row_merge/case.toml new file mode 100644 index 0000000000..422c895baa --- /dev/null +++ b/tests/compatibility/cases/last_row_merge/case.toml @@ -0,0 +1,8 @@ +name = "last_row_merge" +reason = "Verify data written with merge_mode='last_row' by old binaries is still merged correctly by newer binaries." +introduced_by = "PR #8065" +topologies = ["distributed"] +from_range = ["*"] +to_range = ["*"] +features = ["table", "merge"] +owner = "query" diff --git a/tests/compatibility/cases/last_row_merge/setup.sql b/tests/compatibility/cases/last_row_merge/setup.sql new file mode 100644 index 0000000000..26c8b59e09 --- /dev/null +++ b/tests/compatibility/cases/last_row_merge/setup.sql @@ -0,0 +1,19 @@ +CREATE TABLE t_last_row_merge( + host STRING, + ts TIMESTAMP TIME INDEX, + cpu DOUBLE, + memory DOUBLE, + PRIMARY KEY(host) +) +ENGINE=mito +WITH('merge_mode'='last_row'); + +INSERT INTO t_last_row_merge VALUES +('host1', 0, 0, NULL), +('host2', 1, NULL, 1); + +INSERT INTO t_last_row_merge VALUES +('host1', 0, NULL, 10), +('host2', 1, 11, NULL); + +ADMIN FLUSH_TABLE('t_last_row_merge'); diff --git a/tests/compatibility/cases/last_row_merge/verify.result b/tests/compatibility/cases/last_row_merge/verify.result new file mode 100644 index 0000000000..06bd1f6d23 --- /dev/null +++ b/tests/compatibility/cases/last_row_merge/verify.result @@ -0,0 +1,41 @@ +SELECT host, ts, cpu, memory +FROM t_last_row_merge +ORDER BY host, ts; + ++-------+-------------------------+------+--------+ +| host | ts | cpu | memory | ++-------+-------------------------+------+--------+ +| host1 | 1970-01-01T00:00:00 | | 10.0 | +| host2 | 1970-01-01T00:00:00.001 | 11.0 | | ++-------+-------------------------+------+--------+ + +SELECT host, cpu, memory +FROM t_last_row_merge +WHERE memory IS NULL +ORDER BY host; + ++-------+------+--------+ +| host | cpu | memory | ++-------+------+--------+ +| host2 | 11.0 | | ++-------+------+--------+ + +SHOW CREATE TABLE t_last_row_merge; + ++------------------+-------------------------------------------------+ +| Table | Create Table | ++------------------+-------------------------------------------------+ +| t_last_row_merge | CREATE TABLE IF NOT EXISTS "t_last_row_merge" ( | +| | "host" STRING NULL, | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "cpu" DOUBLE NULL, | +| | "memory" DOUBLE NULL, | +| | TIME INDEX ("ts"), | +| | PRIMARY KEY ("host") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | merge_mode = 'last_row' | +| | ) | ++------------------+-------------------------------------------------+ diff --git a/tests/compatibility/cases/last_row_merge/verify.sql b/tests/compatibility/cases/last_row_merge/verify.sql new file mode 100644 index 0000000000..e95951e372 --- /dev/null +++ b/tests/compatibility/cases/last_row_merge/verify.sql @@ -0,0 +1,10 @@ +SELECT host, ts, cpu, memory +FROM t_last_row_merge +ORDER BY host, ts; + +SELECT host, cpu, memory +FROM t_last_row_merge +WHERE memory IS NULL +ORDER BY host; + +SHOW CREATE TABLE t_last_row_merge; diff --git a/tests/compatibility/cases/legacy_json_non_object/case.toml b/tests/compatibility/cases/legacy_json_non_object/case.toml new file mode 100644 index 0000000000..e99035c6c3 --- /dev/null +++ b/tests/compatibility/cases/legacy_json_non_object/case.toml @@ -0,0 +1,8 @@ +name = "legacy_json_non_object" +reason = "Verify non-object JSON values written by old JSONB binaries remain readable after JSON2 non-object write rejection changes." +introduced_by = "PR #8381" +topologies = ["distributed"] +from_range = ["<=v1.1.0"] +to_range = [">=v1.2.0"] +features = ["json", "table"] +owner = "query" diff --git a/tests/compatibility/cases/legacy_json_non_object/setup.sql b/tests/compatibility/cases/legacy_json_non_object/setup.sql new file mode 100644 index 0000000000..defe83e28b --- /dev/null +++ b/tests/compatibility/cases/legacy_json_non_object/setup.sql @@ -0,0 +1,15 @@ +CREATE TABLE t_legacy_json_non_object( + ts TIMESTAMP TIME INDEX, + kind STRING PRIMARY KEY, + j JSON +); + +INSERT INTO t_legacy_json_non_object VALUES +('2024-02-06 00:00:00+0000', 'array', parse_json('[1, 2, 3]')), +('2024-02-06 00:01:00+0000', 'string', parse_json('"hello"')), +('2024-02-06 00:02:00+0000', 'int', parse_json('42')), +('2024-02-06 00:03:00+0000', 'bool', parse_json('true')), +('2024-02-06 00:04:00+0000', 'null', parse_json('null')), +('2024-02-06 00:05:00+0000', 'object', parse_json('{"a": 10, "msg": "object"}')); + +ADMIN FLUSH_TABLE('t_legacy_json_non_object'); diff --git a/tests/compatibility/cases/legacy_json_non_object/verify.result b/tests/compatibility/cases/legacy_json_non_object/verify.result new file mode 100644 index 0000000000..5fc4e397f7 --- /dev/null +++ b/tests/compatibility/cases/legacy_json_non_object/verify.result @@ -0,0 +1,60 @@ +SELECT kind, json_to_string(j) FROM t_legacy_json_non_object ORDER BY kind; + ++--------+--------------------------------------------+ +| kind | json_to_string(t_legacy_json_non_object.j) | ++--------+--------------------------------------------+ +| array | [1,2,3] | +| bool | true | +| int | 42 | +| null | null | +| object | {"a":10,"msg":"object"} | +| string | "hello" | ++--------+--------------------------------------------+ + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_array(j) ORDER BY kind; + ++-------+ +| kind | ++-------+ +| array | ++-------+ + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_string(j) ORDER BY kind; + ++--------+ +| kind | ++--------+ +| string | ++--------+ + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_int(j) ORDER BY kind; + ++------+ +| kind | ++------+ +| int | ++------+ + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_bool(j) ORDER BY kind; + ++------+ +| kind | ++------+ +| bool | ++------+ + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_null(j) ORDER BY kind; + ++------+ +| kind | ++------+ +| null | ++------+ + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_object(j) ORDER BY kind; + ++--------+ +| kind | ++--------+ +| object | ++--------+ diff --git a/tests/compatibility/cases/legacy_json_non_object/verify.sql b/tests/compatibility/cases/legacy_json_non_object/verify.sql new file mode 100644 index 0000000000..2ccf71a21a --- /dev/null +++ b/tests/compatibility/cases/legacy_json_non_object/verify.sql @@ -0,0 +1,13 @@ +SELECT kind, json_to_string(j) FROM t_legacy_json_non_object ORDER BY kind; + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_array(j) ORDER BY kind; + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_string(j) ORDER BY kind; + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_int(j) ORDER BY kind; + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_bool(j) ORDER BY kind; + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_null(j) ORDER BY kind; + +SELECT kind FROM t_legacy_json_non_object WHERE json_is_object(j) ORDER BY kind; diff --git a/tests/compatibility/cases/prefiltered_read/case.toml b/tests/compatibility/cases/prefiltered_read/case.toml new file mode 100644 index 0000000000..7d92cac5cb --- /dev/null +++ b/tests/compatibility/cases/prefiltered_read/case.toml @@ -0,0 +1,8 @@ +name = "prefiltered_read" +reason = "Verify newer read-path prefiltering returns correct rows from SSTs written by old binaries." +introduced_by = "PR #7972" +topologies = ["distributed"] +from_range = ["*"] +to_range = ["*"] +features = ["table", "read", "prefilter"] +owner = "storage" diff --git a/tests/compatibility/cases/prefiltered_read/setup.sql b/tests/compatibility/cases/prefiltered_read/setup.sql new file mode 100644 index 0000000000..83257c5668 --- /dev/null +++ b/tests/compatibility/cases/prefiltered_read/setup.sql @@ -0,0 +1,17 @@ +CREATE TABLE t_prefiltered_read( + ts TIMESTAMP TIME INDEX, + host STRING PRIMARY KEY, + site STRING, + val INT, + cpu_load DOUBLE, + active BOOLEAN +); + +INSERT INTO t_prefiltered_read VALUES +('2024-02-04 00:00:00+0000', 'host_a', 'us-east', 1, 0.10, true), +('2024-02-04 00:01:00+0000', 'host_b', 'us-east', 5, 0.50, false), +('2024-02-04 00:02:00+0000', 'host_c', 'eu-west', 8, 0.80, true), +('2024-02-04 00:03:00+0000', 'host_d', 'eu-west', 13, 1.30, false), +('2024-02-04 00:04:00+0000', 'host_e', 'ap-south', 21, 2.10, true); + +ADMIN FLUSH_TABLE('t_prefiltered_read'); diff --git a/tests/compatibility/cases/prefiltered_read/verify.result b/tests/compatibility/cases/prefiltered_read/verify.result new file mode 100644 index 0000000000..7b39207026 --- /dev/null +++ b/tests/compatibility/cases/prefiltered_read/verify.result @@ -0,0 +1,42 @@ +SELECT host, site, val, cpu_load, active +FROM t_prefiltered_read +WHERE val >= 5 AND val <= 13 +ORDER BY host; + ++--------+---------+-----+----------+--------+ +| host | site | val | cpu_load | active | ++--------+---------+-----+----------+--------+ +| host_b | us-east | 5 | 0.5 | false | +| host_c | eu-west | 8 | 0.8 | true | +| host_d | eu-west | 13 | 1.3 | false | ++--------+---------+-----+----------+--------+ + +SELECT host, val +FROM t_prefiltered_read +WHERE site = 'eu-west' AND active = true +ORDER BY host; + ++--------+-----+ +| host | val | ++--------+-----+ +| host_c | 8 | ++--------+-----+ + +SELECT count(*) FROM t_prefiltered_read WHERE cpu_load > 0.40 AND host != 'host_e'; + ++----------+ +| count(*) | ++----------+ +| 3 | ++----------+ + +SELECT host +FROM t_prefiltered_read +WHERE site IN ('us-east', 'ap-south') AND val > 10 +ORDER BY host; + ++--------+ +| host | ++--------+ +| host_e | ++--------+ diff --git a/tests/compatibility/cases/prefiltered_read/verify.sql b/tests/compatibility/cases/prefiltered_read/verify.sql new file mode 100644 index 0000000000..505369510a --- /dev/null +++ b/tests/compatibility/cases/prefiltered_read/verify.sql @@ -0,0 +1,16 @@ +SELECT host, site, val, cpu_load, active +FROM t_prefiltered_read +WHERE val >= 5 AND val <= 13 +ORDER BY host; + +SELECT host, val +FROM t_prefiltered_read +WHERE site = 'eu-west' AND active = true +ORDER BY host; + +SELECT count(*) FROM t_prefiltered_read WHERE cpu_load > 0.40 AND host != 'host_e'; + +SELECT host +FROM t_prefiltered_read +WHERE site IN ('us-east', 'ap-south') AND val > 10 +ORDER BY host; diff --git a/tests/compatibility/cases/table_ttl/case.toml b/tests/compatibility/cases/table_ttl/case.toml new file mode 100644 index 0000000000..572d7a19b1 --- /dev/null +++ b/tests/compatibility/cases/table_ttl/case.toml @@ -0,0 +1,8 @@ +name = "table_ttl" +reason = "Verify table TTL metadata created by old binaries is preserved and can be changed after upgrade." +introduced_by = "PR #8352" +topologies = ["distributed"] +from_range = ["*"] +to_range = ["*"] +features = ["table", "ttl"] +owner = "storage" diff --git a/tests/compatibility/cases/table_ttl/setup.sql b/tests/compatibility/cases/table_ttl/setup.sql new file mode 100644 index 0000000000..d2cc4c175c --- /dev/null +++ b/tests/compatibility/cases/table_ttl/setup.sql @@ -0,0 +1,12 @@ +CREATE TABLE t_table_ttl( + ts TIMESTAMP TIME INDEX, + host STRING PRIMARY KEY, + val INT +) +WITH('ttl'='7d'); + +INSERT INTO t_table_ttl VALUES +('2099-02-08 00:00:00+0000', 'host_a', 1), +('2099-02-08 00:01:00+0000', 'host_b', 2); + +ADMIN FLUSH_TABLE('t_table_ttl'); diff --git a/tests/compatibility/cases/table_ttl/verify.result b/tests/compatibility/cases/table_ttl/verify.result new file mode 100644 index 0000000000..6a97f3242b --- /dev/null +++ b/tests/compatibility/cases/table_ttl/verify.result @@ -0,0 +1,65 @@ +SELECT ts, host, val FROM t_table_ttl ORDER BY ts, host; + ++---------------------+--------+-----+ +| ts | host | val | ++---------------------+--------+-----+ +| 2099-02-08T00:00:00 | host_a | 1 | +| 2099-02-08T00:01:00 | host_b | 2 | ++---------------------+--------+-----+ + +SHOW CREATE TABLE t_table_ttl; + ++-------------+--------------------------------------------+ +| Table | Create Table | ++-------------+--------------------------------------------+ +| t_table_ttl | CREATE TABLE IF NOT EXISTS "t_table_ttl" ( | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "host" STRING NULL, | +| | "val" INT NULL, | +| | TIME INDEX ("ts"), | +| | PRIMARY KEY ("host") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | ttl = '7days' | +| | ) | ++-------------+--------------------------------------------+ + +ALTER TABLE t_table_ttl SET 'ttl' = '30d'; + +Affected Rows: 0 + +SHOW CREATE TABLE t_table_ttl; + ++-------------+--------------------------------------------+ +| Table | Create Table | ++-------------+--------------------------------------------+ +| t_table_ttl | CREATE TABLE IF NOT EXISTS "t_table_ttl" ( | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "host" STRING NULL, | +| | "val" INT NULL, | +| | TIME INDEX ("ts"), | +| | PRIMARY KEY ("host") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | ttl = '30days' | +| | ) | ++-------------+--------------------------------------------+ + +INSERT INTO t_table_ttl VALUES +('2099-02-08 00:02:00+0000', 'host_c', 3); + +Affected Rows: 1 + +SELECT ts, host, val FROM t_table_ttl ORDER BY ts, host; + ++---------------------+--------+-----+ +| ts | host | val | ++---------------------+--------+-----+ +| 2099-02-08T00:00:00 | host_a | 1 | +| 2099-02-08T00:01:00 | host_b | 2 | +| 2099-02-08T00:02:00 | host_c | 3 | ++---------------------+--------+-----+ diff --git a/tests/compatibility/cases/table_ttl/verify.sql b/tests/compatibility/cases/table_ttl/verify.sql new file mode 100644 index 0000000000..cd58864148 --- /dev/null +++ b/tests/compatibility/cases/table_ttl/verify.sql @@ -0,0 +1,12 @@ +SELECT ts, host, val FROM t_table_ttl ORDER BY ts, host; + +SHOW CREATE TABLE t_table_ttl; + +ALTER TABLE t_table_ttl SET 'ttl' = '30d'; + +SHOW CREATE TABLE t_table_ttl; + +INSERT INTO t_table_ttl VALUES +('2099-02-08 00:02:00+0000', 'host_c', 3); + +SELECT ts, host, val FROM t_table_ttl ORDER BY ts, host;