mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-31 20:30:37 +00:00
* feat: add validate method to CreateExpr Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add sqlness reproducer Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * verify region create request Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix existing test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add tailing empty line Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add more validation Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix typo Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * disable metric table fuzz Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * minor refactor Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
172 lines
7.4 KiB
Plaintext
172 lines
7.4 KiB
Plaintext
CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "");
|
|
|
|
Affected Rows: 0
|
|
|
|
SHOW TABLES;
|
|
|
|
+---------+
|
|
| Tables |
|
|
+---------+
|
|
| numbers |
|
|
| phy |
|
|
+---------+
|
|
|
|
DESC TABLE phy;
|
|
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
|
| val | Float64 | | YES | | FIELD |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
|
|
-- create table with duplicate column def
|
|
CREATE TABLE t1(ts timestamp time index, val double, host text, host string) engine=metric with ("on_physical_table" = "phy");
|
|
|
|
Error: 1004(InvalidArguments), Invalid SQL, error: column name `host` is duplicated at index 2 and 3
|
|
|
|
CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
|
|
|
|
Affected Rows: 0
|
|
|
|
-- create logical table with different data type on field column
|
|
CREATE TABLE t3 (ts timestamp time index, val string, host string, primary key (host)) engine=metric with ("on_physical_table" = "phy");
|
|
|
|
Error: 1004(InvalidArguments), Column type mismatch. Expect Float64(Float64Type), got String(StringType)
|
|
|
|
-- create logical table with different data type on tag column
|
|
CREATE TABLE t4 (ts timestamp time index, val double, host double, primary key (host)) engine=metric with ("on_physical_table" = "phy");
|
|
|
|
Error: 1004(InvalidArguments), Column type mismatch. Expect String(StringType), got Float64(Float64Type)
|
|
|
|
-- create logical table with different column name on field column
|
|
CREATE TABLE t5 (ts timestamp time index, valval double, host string primary key) engine = metric with ("on_physical_table" = "phy");
|
|
|
|
Error: 1004(InvalidArguments), Adding field column valval to physical table
|
|
|
|
SELECT table_catalog, table_schema, table_name, table_type, engine FROM information_schema.tables WHERE engine = 'metric' order by table_name;
|
|
|
|
+---------------+--------------+------------+------------+--------+
|
|
| table_catalog | table_schema | table_name | table_type | engine |
|
|
+---------------+--------------+------------+------------+--------+
|
|
| greptime | public | phy | BASE TABLE | metric |
|
|
| greptime | public | t1 | BASE TABLE | metric |
|
|
| greptime | public | t2 | BASE TABLE | metric |
|
|
+---------------+--------------+------------+------------+--------+
|
|
|
|
DESC TABLE phy;
|
|
|
|
+------------+----------------------+-----+------+---------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+------------+----------------------+-----+------+---------+---------------+
|
|
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
|
| val | Float64 | | YES | | FIELD |
|
|
| __table_id | UInt32 | PRI | NO | | TAG |
|
|
| __tsid | UInt64 | PRI | NO | | TAG |
|
|
| host | String | PRI | YES | | TAG |
|
|
| job | String | PRI | YES | | TAG |
|
|
+------------+----------------------+-----+------+---------+---------------+
|
|
|
|
DESC TABLE t1;
|
|
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| host | String | PRI | YES | | TAG |
|
|
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
|
| val | Float64 | | YES | | FIELD |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
|
|
DESC TABLE t2;
|
|
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| job | String | PRI | YES | | TAG |
|
|
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
|
| val | Float64 | | YES | | FIELD |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
|
|
-- should be failed
|
|
-- SQLNESS REPLACE (region\s\d+\(\d+\,\s\d+\)) region
|
|
DROP TABLE phy;
|
|
|
|
Error: 1004(InvalidArguments), Physical region is busy, there are still some logical regions using it
|
|
|
|
-- metadata should be restored
|
|
DESC TABLE phy;
|
|
|
|
+------------+----------------------+-----+------+---------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+------------+----------------------+-----+------+---------+---------------+
|
|
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
|
| val | Float64 | | YES | | FIELD |
|
|
| __table_id | UInt32 | PRI | NO | | TAG |
|
|
| __tsid | UInt64 | PRI | NO | | TAG |
|
|
| host | String | PRI | YES | | TAG |
|
|
| job | String | PRI | YES | | TAG |
|
|
+------------+----------------------+-----+------+---------+---------------+
|
|
|
|
DROP TABLE t1;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE t2;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE phy;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- create one with other primary keys
|
|
CREATE TABLE phy2 (ts timestamp time index, val double, abc string, def string, primary key (abc, def)) engine=metric with ("physical_metric_table" = "");
|
|
|
|
Affected Rows: 0
|
|
|
|
DESC TABLE phy2;
|
|
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
|
| val | Float64 | | YES | | FIELD |
|
|
| abc | String | PRI | YES | | TAG |
|
|
| def | String | PRI | YES | | TAG |
|
|
+--------+----------------------+-----+------+---------+---------------+
|
|
|
|
DROP TABLE phy2;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- fuzz test case https://github.com/GreptimeTeam/greptimedb/issues/3612
|
|
CREATE TABLE `auT`(
|
|
incidunt TIMESTAMP(3) TIME INDEX,
|
|
`REPREHenDERIt` double DEFAULT 0.70978713,
|
|
`cOMmodi` STRING,
|
|
`PERfERENdIS` STRING,
|
|
PRIMARY KEY(`cOMmodi`, `PERfERENdIS`)
|
|
) ENGINE = metric with ("physical_metric_table" = "");
|
|
|
|
Affected Rows: 0
|
|
|
|
DESC TABLE `auT`;
|
|
|
|
+---------------+----------------------+-----+------+------------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+---------------+----------------------+-----+------+------------+---------------+
|
|
| incidunt | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
|
| REPREHenDERIt | Float64 | | YES | 0.70978713 | FIELD |
|
|
| cOMmodi | String | PRI | YES | | TAG |
|
|
| PERfERENdIS | String | PRI | YES | | TAG |
|
|
+---------------+----------------------+-----+------+------------+---------------+
|
|
|
|
DROP TABLE `auT`;
|
|
|
|
Affected Rows: 0
|
|
|