mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 20:54:08 +00:00
* test: add inverted index compatibility case (#5188) Signed-off-by: NightG1owZ <316247938+NightG1owZ@users.noreply.github.com> * test(compat): assert the newly indexed column stays queryable (#9535) Signed-off-by: NightG1owZ <316247938+NightG1owZ@users.noreply.github.com> * test(compat): narrow to_range to versions carrying #9545 The filtered read added in the previous commit only returns rows once #9545 is present. That fix is on main only (no backport-* labels), so it ships in the v1.4.0 line. Narrow to_range to >=v1.4.0-alpha.0 so the documented downgrade invocation (--to-version v1.1.4) is not broken. Also add the missing trailing newline to the three case files. Signed-off-by: NightG1owZ <316247938+NightG1owZ@users.noreply.github.com> --------- Signed-off-by: NightG1owZ <316247938+NightG1owZ@users.noreply.github.com> Co-authored-by: NightG1owZ <316247938+NightG1owZ@users.noreply.github.com>
146 lines
6.6 KiB
Plaintext
146 lines
6.6 KiB
Plaintext
-- 1. Index metadata written by the old binary must survive.
|
|
SHOW CREATE TABLE t_inverted_index_survival;
|
|
|
|
+---------------------------+----------------------------------------------------------+
|
|
| Table | Create Table |
|
|
+---------------------------+----------------------------------------------------------+
|
|
| t_inverted_index_survival | CREATE TABLE IF NOT EXISTS "t_inverted_index_survival" ( |
|
|
| | "host" STRING NULL INVERTED INDEX, |
|
|
| | "msg" STRING NULL INVERTED INDEX, |
|
|
| | "msg2" STRING NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL, |
|
|
| | "cpu" DOUBLE NULL, |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("host") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | |
|
|
+---------------------------+----------------------------------------------------------+
|
|
|
|
-- 2. Rows written by the old binary must still be readable.
|
|
SELECT host, msg, cpu
|
|
FROM t_inverted_index_survival
|
|
ORDER BY host, ts;
|
|
|
|
+------+--------------+-----+
|
|
| host | msg | cpu |
|
|
+------+--------------+-----+
|
|
| h1 | first event | 1.0 |
|
|
| h2 | second event | 2.0 |
|
|
+------+--------------+-----+
|
|
|
|
-- 3. Filtered read on the column indexed by the old binary.
|
|
SELECT host, msg
|
|
FROM t_inverted_index_survival
|
|
WHERE msg = 'first event'
|
|
ORDER BY host, ts;
|
|
|
|
+------+-------------+
|
|
| host | msg |
|
|
+------+-------------+
|
|
| h1 | first event |
|
|
+------+-------------+
|
|
|
|
-- 4. The new binary must still be able to write into the old table.
|
|
INSERT INTO t_inverted_index_survival VALUES
|
|
('h3', 'third event', 'third note', '2026-07-07 00:02:00+0000', 3.0);
|
|
|
|
Affected Rows: 1
|
|
|
|
SELECT host, msg, cpu
|
|
FROM t_inverted_index_survival
|
|
ORDER BY host, ts;
|
|
|
|
+------+--------------+-----+
|
|
| host | msg | cpu |
|
|
+------+--------------+-----+
|
|
| h1 | first event | 1.0 |
|
|
| h2 | second event | 2.0 |
|
|
| h3 | third event | 3.0 |
|
|
+------+--------------+-----+
|
|
|
|
-- 5. Enabling an index on an existing column must keep SSTs written before the
|
|
-- index existed readable (regression guard for #9535). 'first note' and
|
|
-- 'second note' live in the SST written by the old binary, which carries
|
|
-- inverted indexes for host/msg but not for msg2.
|
|
ALTER TABLE t_inverted_index_survival MODIFY COLUMN msg2 SET INVERTED INDEX;
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW CREATE TABLE t_inverted_index_survival;
|
|
|
|
+---------------------------+----------------------------------------------------------+
|
|
| Table | Create Table |
|
|
+---------------------------+----------------------------------------------------------+
|
|
| t_inverted_index_survival | CREATE TABLE IF NOT EXISTS "t_inverted_index_survival" ( |
|
|
| | "host" STRING NULL INVERTED INDEX, |
|
|
| | "msg" STRING NULL INVERTED INDEX, |
|
|
| | "msg2" STRING NULL INVERTED INDEX, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL, |
|
|
| | "cpu" DOUBLE NULL, |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("host") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | |
|
|
+---------------------------+----------------------------------------------------------+
|
|
|
|
SELECT host, msg2
|
|
FROM t_inverted_index_survival
|
|
WHERE msg2 = 'first note'
|
|
ORDER BY host, ts;
|
|
|
|
+------+------------+
|
|
| host | msg2 |
|
|
+------+------------+
|
|
| h1 | first note |
|
|
+------+------------+
|
|
|
|
SELECT host, msg2
|
|
FROM t_inverted_index_survival
|
|
WHERE msg2 = 'second note'
|
|
ORDER BY host, ts;
|
|
|
|
+------+-------------+
|
|
| host | msg2 |
|
|
+------+-------------+
|
|
| h2 | second note |
|
|
+------+-------------+
|
|
|
|
-- A non-matching predicate must still return nothing.
|
|
SELECT host, msg2
|
|
FROM t_inverted_index_survival
|
|
WHERE msg2 = 'no such note'
|
|
ORDER BY host, ts;
|
|
|
|
+------+------+
|
|
| host | msg2 |
|
|
+------+------+
|
|
+------+------+
|
|
|
|
-- 6. The index can still be removed afterwards.
|
|
ALTER TABLE t_inverted_index_survival MODIFY COLUMN msg2 UNSET INVERTED INDEX;
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW CREATE TABLE t_inverted_index_survival;
|
|
|
|
+---------------------------+----------------------------------------------------------+
|
|
| Table | Create Table |
|
|
+---------------------------+----------------------------------------------------------+
|
|
| t_inverted_index_survival | CREATE TABLE IF NOT EXISTS "t_inverted_index_survival" ( |
|
|
| | "host" STRING NULL INVERTED INDEX, |
|
|
| | "msg" STRING NULL INVERTED INDEX, |
|
|
| | "msg2" STRING NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL, |
|
|
| | "cpu" DOUBLE NULL, |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("host") |
|
|
| | ) |
|
|
| | |
|
|
| | ENGINE=mito |
|
|
| | |
|
|
+---------------------------+----------------------------------------------------------+
|