Files
greptimedb/tests/cases/standalone/create/create.result
dennis zhuang d195a22f40 fix: parsing time index column option (#865)
* fix: parsing time index column option

* test: adds more cases for creating table

* chore: by CR comments

* feat: validate time index constraint in parser

* chore: improve error msg
2023-01-13 13:22:12 +08:00

91 lines
2.5 KiB
Plaintext

CREATE TABLE integers (i BIGINT);
Error: 2000(InvalidSyntax), Missing time index constraint
CREATE TABLE integers (i INT TIME INDEX);
Error: 1004(InvalidArguments), Invalid column option, column name: i, error: time index column data type should be timestamp or bigint
CREATE TABLE integers (i BIGINT TIME INDEX NULL);
Error: 1004(InvalidArguments), Invalid column option, column name: i, error: time index column can't be null
CREATE TABLE integers (i BIGINT TIME INDEX, j BIGINT, TIME INDEX(j));
Error: 2000(InvalidSyntax), Invalid time index: expected only one time index constraint but actual 2
CREATE TABLE integers (i BIGINT TIME INDEX, j BIGINT, TIME INDEX(i, j));
Error: 2000(InvalidSyntax), Invalid time index: it should contain only one column in time index
CREATE TABLE integers (i BIGINT TIME INDEX);
Affected Rows: 0
CREATE TABLE times (i TIMESTAMP TIME INDEX DEFAULT CURRENT_TIMESTAMP);
Affected Rows: 0
CREATE TABLE IF NOT EXISTS integers (i BIGINT TIME INDEX);
Affected Rows: 0
CREATE TABLE test1 (i INTEGER, j INTEGER);
Error: 2000(InvalidSyntax), Missing time index constraint
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX NOT NULL);
Affected Rows: 0
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX NULL);
Error: 1004(InvalidArguments), Invalid column option, column name: j, error: time index column can't be null
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
DESC TABLE integers;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
DESC TABLE test1;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | VALUE |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
DESC TABLE test2;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | VALUE |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
DROP TABLE integers;
Affected Rows: 1
DROP TABLE times;
Affected Rows: 1
DROP TABLE test1;
Affected Rows: 1
DROP TABLE test2;
Affected Rows: 1