Files
greptimedb/tests/cases/standalone/common/show/show_index.result
T
dennis zhuang ca21c9f048 fix!: correct information_schema index metadata (#8275)
fix: correct information_schema index metadata

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-06-11 01:36:23 +00:00

164 lines
14 KiB
Plaintext

CREATE TABLE IF NOT EXISTS system_metrics (
host STRING,
idc STRING FULLTEXT INDEX INVERTED INDEX,
cpu_util DOUBLE,
memory_util DOUBLE,
disk_util DOUBLE,
desc1 STRING,
desc2 STRING FULLTEXT INDEX,
desc3 STRING FULLTEXT INDEX,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(host, idc),
TIME INDEX(ts)
);
Affected Rows: 0
CREATE TABLE IF NOT EXISTS test (
a STRING,
b STRING SKIPPING INDEX,
c DOUBLE,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(a, b),
TIME INDEX(ts)
);
Affected Rows: 0
CREATE TABLE IF NOT EXISTS test_no_inverted_index (
a STRING,
b STRING SKIPPING INDEX,
c DOUBLE,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(a, b),
TIME INDEX(ts)
);
Affected Rows: 0
show create table test_no_inverted_index;
+------------------------+-------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------------------+-------------------------------------------------------------------------------------------------------------+
| test_no_inverted_index | CREATE TABLE IF NOT EXISTS "test_no_inverted_index" ( |
| | "a" STRING NULL, |
| | "b" STRING NULL SKIPPING INDEX WITH(false_positive_rate = '0.01', granularity = '10240', type = 'BLOOM'), |
| | "c" DOUBLE NULL, |
| | "ts" TIMESTAMP(3) NOT NULL DEFAULT current_timestamp(), |
| | TIME INDEX ("ts"), |
| | PRIMARY KEY ("a", "b") |
| | ) |
| | |
| | ENGINE=mito |
| | |
+------------------------+-------------------------------------------------------------------------------------------------------------+
SHOW INDEX;
Error: 2000(InvalidSyntax), Unexpected token while parsing SQL statement, expected: '{FROM | IN} table', found: ;
SHOW INDEX FROM test;
+-------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+-------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| test | 0 | PRIMARY | 1 | a | A | | | | YES | PRIMARY | | | YES | |
| test | 0 | PRIMARY | 2 | b | A | | | | YES | PRIMARY | | | YES | |
| test | 1 | SKIPPING_INDEX_b | 1 | b | A | | | | YES | SKIPPING | | | YES | |
| test | 1 | TIME INDEX | 1 | ts | A | | | | | TIME | | | YES | |
+-------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
SHOW INDEX FROM test_no_inverted_index;
+------------------------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+------------------------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| test_no_inverted_index | 0 | PRIMARY | 1 | a | A | | | | YES | PRIMARY | | | YES | |
| test_no_inverted_index | 0 | PRIMARY | 2 | b | A | | | | YES | PRIMARY | | | YES | |
| test_no_inverted_index | 1 | SKIPPING_INDEX_b | 1 | b | A | | | | YES | SKIPPING | | | YES | |
| test_no_inverted_index | 1 | TIME INDEX | 1 | ts | A | | | | | TIME | | | YES | |
+------------------------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
SHOW INDEX FROM system_metrics;
+----------------+------------+----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+----------------+------------+----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| system_metrics | 1 | FULLTEXT_INDEX_desc2 | 1 | desc2 | A | | | | YES | FULLTEXT | | | YES | |
| system_metrics | 1 | FULLTEXT_INDEX_desc3 | 1 | desc3 | A | | | | YES | FULLTEXT | | | YES | |
| system_metrics | 1 | FULLTEXT_INDEX_idc | 1 | idc | A | | | | YES | FULLTEXT | | | YES | |
| system_metrics | 1 | INVERTED_INDEX_idc | 1 | idc | A | | | | YES | INVERTED | | | YES | |
| system_metrics | 0 | PRIMARY | 1 | host | A | | | | YES | PRIMARY | | | YES | |
| system_metrics | 0 | PRIMARY | 2 | idc | A | | | | YES | PRIMARY | | | YES | |
| system_metrics | 1 | TIME INDEX | 1 | ts | A | | | | | TIME | | | YES | |
+----------------+------------+----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
SHOW INDEX FROM system_metrics in public;
+----------------+------------+----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+----------------+------------+----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| system_metrics | 1 | FULLTEXT_INDEX_desc2 | 1 | desc2 | A | | | | YES | FULLTEXT | | | YES | |
| system_metrics | 1 | FULLTEXT_INDEX_desc3 | 1 | desc3 | A | | | | YES | FULLTEXT | | | YES | |
| system_metrics | 1 | FULLTEXT_INDEX_idc | 1 | idc | A | | | | YES | FULLTEXT | | | YES | |
| system_metrics | 1 | INVERTED_INDEX_idc | 1 | idc | A | | | | YES | INVERTED | | | YES | |
| system_metrics | 0 | PRIMARY | 1 | host | A | | | | YES | PRIMARY | | | YES | |
| system_metrics | 0 | PRIMARY | 2 | idc | A | | | | YES | PRIMARY | | | YES | |
| system_metrics | 1 | TIME INDEX | 1 | ts | A | | | | | TIME | | | YES | |
+----------------+------------+----------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
SHOW INDEX FROM system_metrics like '%util%';
Error: 1001(Unsupported), SQL statement is not supported, keyword: like
SHOW INDEX FROM system_metrics WHERE Key_name = 'TIME INDEX';
+----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| system_metrics | 1 | TIME INDEX | 1 | ts | A | | | | | TIME | | | YES | |
+----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
SELECT table_schema,
table_name,
non_unique,
index_name,
seq_in_index,
column_name,
index_type,
greptime_index_type
FROM information_schema.statistics
WHERE table_schema = 'public'
AND table_name IN ('system_metrics', 'test')
ORDER BY table_name, index_name, seq_in_index, column_name;
+--------------+----------------+------------+----------------------+--------------+-------------+------------+---------------------+
| table_schema | table_name | non_unique | index_name | seq_in_index | column_name | index_type | greptime_index_type |
+--------------+----------------+------------+----------------------+--------------+-------------+------------+---------------------+
| public | system_metrics | 1 | FULLTEXT_INDEX_desc2 | 1 | desc2 | FULLTEXT | fulltext_bloom |
| public | system_metrics | 1 | FULLTEXT_INDEX_desc3 | 1 | desc3 | FULLTEXT | fulltext_bloom |
| public | system_metrics | 1 | FULLTEXT_INDEX_idc | 1 | idc | FULLTEXT | fulltext_bloom |
| public | system_metrics | 1 | INVERTED_INDEX_idc | 1 | idc | INVERTED | inverted |
| public | system_metrics | 0 | PRIMARY | 1 | host | PRIMARY | dense |
| public | system_metrics | 0 | PRIMARY | 2 | idc | PRIMARY | dense |
| public | system_metrics | 1 | TIME INDEX | 1 | ts | TIME | |
| public | test | 0 | PRIMARY | 1 | a | PRIMARY | dense |
| public | test | 0 | PRIMARY | 2 | b | PRIMARY | dense |
| public | test | 1 | SKIPPING_INDEX_b | 1 | b | SKIPPING | bloom_filter |
| public | test | 1 | TIME INDEX | 1 | ts | TIME | |
+--------------+----------------+------------+----------------------+--------------+-------------+------------+---------------------+
DROP TABLE system_metrics;
Affected Rows: 0
DROP TABLE test;
Affected Rows: 0
DROP TABLE test_no_inverted_index;
Affected Rows: 0