From 9c6d8ca3f341e4b161177a4aa88b7c12d4b980d3 Mon Sep 17 00:00:00 2001
From: "kyle.cao" <kyle.cao@vesoft.com>
Date: Mon, 9 Jan 2023 10:46:29 +0800
Subject: [PATCH] Add test cases for DDL

---
 tests/tck/features/bugfix/Ddl.feature | 144 ++++++++++++++++++++++++++
 1 file changed, 144 insertions(+)
 create mode 100644 tests/tck/features/bugfix/Ddl.feature

diff --git a/tests/tck/features/bugfix/Ddl.feature b/tests/tck/features/bugfix/Ddl.feature
new file mode 100644
index 00000000000..5290bd17148
--- /dev/null
+++ b/tests/tck/features/bugfix/Ddl.feature
@@ -0,0 +1,144 @@
+# Copyright (c) 2023 vesoft inc. All rights reserved.
+#
+# This source code is licensed under Apache 2.0 License.
+Feature: DDL test
+
+  Background:
+    Given an empty graph
+    And create a space with following options:
+      | partition_num  | 1                |
+      | replica_factor | 1                |
+      | vid_type       | FIXED_STRING(30) |
+      | charset        | utf8             |
+      | collate        | utf8_bin         |
+
+  Scenario: Create tag
+    When executing query:
+      """
+      CREATE TAG A();
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE TAG IF NOT EXISTS A(id int, name string);
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE TAG IF NOT EXISTS B(
+        id int NOT NULL DEFAULT 0+0 COMMENT "primary key",
+        name string NOT NULL,
+        createDate DATETIME, location geography(polygon),
+        isVisited bool COMMENT "kHop search flag",
+        nickName TIME DEFAULT time()
+        )
+        TTL_DURATION = 100, TTL_COL = "id", COMMENT = "TAG B";
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      DESC TAG A;
+      """
+    Then the result should be, in any order:
+      | Field | Type | Null | Default | Comment |
+    When executing query:
+      """
+      DESC TAG B;
+      """
+    Then the result should be, in any order:
+      | Field        | Type                 | Null  | Default  | Comment            |
+      | "id"         | "int64"              | "NO"  | 0        | "primary key"      |
+      | "name"       | "string"             | "NO"  |          |                    |
+      | "createDate" | "datetime"           | "YES" |          |                    |
+      | "location"   | "geography(polygon)" | "YES" |          |                    |
+      | "isVisited"  | "bool"               | "YES" |          | "kHop search flag" |
+      | "nickName"   | "time"               | "YES" | "time()" |                    |
+    When executing query:
+      """
+      CREATE TAG INDEX idx_A_1 on A();
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE TAG INDEX idx_A_2 on A(id);
+      """
+    Then a ExecutionError should be raised at runtime: Key not existed!
+    When executing query:
+      """
+      CREATE TAG INDEX IF NOT EXISTS idx_A_3 on A();
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE TAG INDEX IF NOT EXISTS idx_B_1 on B(isVisited, id, nickName);
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE TAG INDEX IF NOT EXISTS idx_B_2 on B(id, isVisited);
+      """
+    Then the execution should be successful
+
+  Scenario: Create edge
+    When executing query:
+      """
+      CREATE EDGE E1();
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE EDGE IF NOT EXISTS E1(id int, name string);
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE EDGE IF NOT EXISTS E2(
+        id int NOT NULL DEFAULT 0 COMMENT "primary key",
+        name string NOT NULL,
+        createDate DATETIME, location geography(polygon),
+        isVisited bool COMMENT "kHop search flag",
+        nickName TIME DEFAULT time()
+        )
+        TTL_DURATION = 100, TTL_COL = "id", COMMENT = "Edge E2";
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      DESC EDGE E1;
+      """
+    Then the result should be, in any order:
+      | Field | Type | Null | Default | Comment |
+    When executing query:
+      """
+      DESC EDGE E2;
+      """
+    Then the result should be, in any order:
+      | Field        | Type                 | Null  | Default  | Comment            |
+      | "id"         | "int64"              | "NO"  | 0        | "primary key"      |
+      | "name"       | "string"             | "NO"  |          |                    |
+      | "createDate" | "datetime"           | "YES" |          |                    |
+      | "location"   | "geography(polygon)" | "YES" |          |                    |
+      | "isVisited"  | "bool"               | "YES" |          | "kHop search flag" |
+      | "nickName"   | "time"               | "YES" | "time()" |                    |
+    When executing query:
+      """
+      CREATE EDGE INDEX idx_E_1 on E1();
+      """
+    Then the execution should be successful
+    When executing query:
+      """
+      CREATE EDGE INDEX idx_E_2 on E1(id);
+      """
+    Then a ExecutionError should be raised at runtime: Key not existed!
+    When executing query:
+      """
+      CREATE EDGE INDEX IF NOT EXISTS idx_E_3 on E2(isVisited, id, nickName, createDate);
+      """
+    Then the execution should be successful
+
+# issue 5219
+# When executing query:
+# """
+# CREATE EDGE INDEX IF NOT EXISTS idx_E_3 on E2(isVisited, id, nickName, createDate, name);
+# """
+# Then the execution should be successful