From 51fffc43ddbf50c49890a0a0e666acbc80210e92 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Thu, 22 Dec 2022 14:01:14 +0800 Subject: [PATCH 01/17] add a function to check legitimacy --- src/interface/meta.thrift | 3 ++- src/meta/MetaServiceUtils.cpp | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/interface/meta.thrift b/src/interface/meta.thrift index 93c236509ad..8d203b876c0 100644 --- a/src/interface/meta.thrift +++ b/src/interface/meta.thrift @@ -84,7 +84,8 @@ struct ColumnDef { 5: optional binary comment, } -struct SchemaProp { +struct + { 1: optional i64 ttl_duration, 2: optional binary ttl_col, 3: optional binary comment, diff --git a/src/meta/MetaServiceUtils.cpp b/src/meta/MetaServiceUtils.cpp index 3189cf955e3..9445f934f5c 100644 --- a/src/meta/MetaServiceUtils.cpp +++ b/src/meta/MetaServiceUtils.cpp @@ -32,6 +32,40 @@ nebula::cpp2::ErrorCode backupTable(kvstore::KVStore* kvstore, std::make_move_iterator(backupTableFiles.end())); return nebula::cpp2::ErrorCode::SUCCEEDED; } + +bool isLegalTypeConversion(cpp2::ColumnTypeDef from, cpp2::ColumnTypeDef to) { + if (from.get_type() == to.get_type()) { + return true; + } + + // fixed string can be converted to string or larger fixed string + if (from.get_type() == cpp2::PropertyType::FIXED_STRING) { + if (to.get_type() == cpp2::PropertyType::STRING) { + return true; + } else if (to.get_type() == cpp2::PropertyType::FIXED_STRING) { + return from.get_type_length() <= to.get_type_length(); + } else { + return false; + } + } + // int is only allowed to convert to wider int + if (from.get_type() == cpp2::PropertyType::INT32) { + return to.get_type() == cpp2::PropertyType::INT64; + } + if (from.get_type() == cpp2::PropertyType::INT16) { + return to.get_type() == cpp2::PropertyType::INT64 || to.get_type() == cpp2::PropertyType::INT32; + } + if (from.get_type() == cpp2::PropertyType::INT8) { + return to.get_type() == cpp2::PropertyType::INT64 || + to.get_type() == cpp2::PropertyType::INT32 || to.get_type() == cpp2::PropertyType::INT16; + } + // Float is only allowed to convert to double + if (from.get_type() == cpp2::PropertyType::FLOAT) { + return to.get_type() == cpp2::PropertyType::DOUBLE; + } + // Forbid all the other conversion, as the old data are too different from the new data. + return false; +} } // namespace nebula::cpp2::ErrorCode MetaServiceUtils::alterColumnDefs(std::vector& cols, @@ -58,6 +92,11 @@ nebula::cpp2::ErrorCode MetaServiceUtils::alterColumnDefs(std::vectorget_type(), col.get_type())) { + LOG(INFO) << "Update colume type " << colName << " from " << it->get_type() << " to " + << col.get_type() << " is not allowed!"; + return nebula::cpp2::ErrorCode::E_UNSUPPORTED; + } *it = col; return nebula::cpp2::ErrorCode::SUCCEEDED; } From 0e5be9acd74fdba77349acd4c9575f646bbf01fc Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Fri, 23 Dec 2022 10:40:35 +0800 Subject: [PATCH 02/17] fix test --- src/interface/meta.thrift | 3 +- src/meta/MetaServiceUtils.cpp | 36 +++--- src/meta/test/ProcessorTest.cpp | 217 +++++++++++++++++++++++++++++--- 3 files changed, 223 insertions(+), 33 deletions(-) diff --git a/src/interface/meta.thrift b/src/interface/meta.thrift index 8d203b876c0..93c236509ad 100644 --- a/src/interface/meta.thrift +++ b/src/interface/meta.thrift @@ -84,8 +84,7 @@ struct ColumnDef { 5: optional binary comment, } -struct - { +struct SchemaProp { 1: optional i64 ttl_duration, 2: optional binary ttl_col, 3: optional binary comment, diff --git a/src/meta/MetaServiceUtils.cpp b/src/meta/MetaServiceUtils.cpp index 9445f934f5c..a5a13502e8a 100644 --- a/src/meta/MetaServiceUtils.cpp +++ b/src/meta/MetaServiceUtils.cpp @@ -34,34 +34,38 @@ nebula::cpp2::ErrorCode backupTable(kvstore::KVStore* kvstore, } bool isLegalTypeConversion(cpp2::ColumnTypeDef from, cpp2::ColumnTypeDef to) { - if (from.get_type() == to.get_type()) { + // If not type change, return true. Fixed string will be handled separately. + if (from.get_type() == to.get_type() && + from.get_type() != nebula::cpp2::PropertyType::FIXED_STRING) { return true; } // fixed string can be converted to string or larger fixed string - if (from.get_type() == cpp2::PropertyType::FIXED_STRING) { - if (to.get_type() == cpp2::PropertyType::STRING) { + if (from.get_type() == nebula::cpp2::PropertyType::FIXED_STRING) { + if (to.get_type() == nebula::cpp2::PropertyType::STRING) { return true; - } else if (to.get_type() == cpp2::PropertyType::FIXED_STRING) { + } else if (to.get_type() == nebula::cpp2::PropertyType::FIXED_STRING) { return from.get_type_length() <= to.get_type_length(); } else { return false; } } // int is only allowed to convert to wider int - if (from.get_type() == cpp2::PropertyType::INT32) { - return to.get_type() == cpp2::PropertyType::INT64; + if (from.get_type() == nebula::cpp2::PropertyType::INT32) { + return to.get_type() == nebula::cpp2::PropertyType::INT64; } - if (from.get_type() == cpp2::PropertyType::INT16) { - return to.get_type() == cpp2::PropertyType::INT64 || to.get_type() == cpp2::PropertyType::INT32; + if (from.get_type() == nebula::cpp2::PropertyType::INT16) { + return to.get_type() == nebula::cpp2::PropertyType::INT64 || + to.get_type() == nebula::cpp2::PropertyType::INT32; } - if (from.get_type() == cpp2::PropertyType::INT8) { - return to.get_type() == cpp2::PropertyType::INT64 || - to.get_type() == cpp2::PropertyType::INT32 || to.get_type() == cpp2::PropertyType::INT16; + if (from.get_type() == nebula::cpp2::PropertyType::INT8) { + return to.get_type() == nebula::cpp2::PropertyType::INT64 || + to.get_type() == nebula::cpp2::PropertyType::INT32 || + to.get_type() == nebula::cpp2::PropertyType::INT16; } // Float is only allowed to convert to double - if (from.get_type() == cpp2::PropertyType::FLOAT) { - return to.get_type() == cpp2::PropertyType::DOUBLE; + if (from.get_type() == nebula::cpp2::PropertyType::FLOAT) { + return to.get_type() == nebula::cpp2::PropertyType::DOUBLE; } // Forbid all the other conversion, as the old data are too different from the new data. return false; @@ -93,8 +97,10 @@ nebula::cpp2::ErrorCode MetaServiceUtils::alterColumnDefs(std::vectorget_type(), col.get_type())) { - LOG(INFO) << "Update colume type " << colName << " from " << it->get_type() << " to " - << col.get_type() << " is not allowed!"; + LOG(INFO) << "Update colume type " << colName << " from " + << apache::thrift::util::enumNameSafe(it->get_type().get_type()) << " to " + << apache::thrift::util::enumNameSafe(col.get_type().get_type()) + << " is not allowed!"; return nebula::cpp2::ErrorCode::E_UNSUPPORTED; } *it = col; diff --git a/src/meta/test/ProcessorTest.cpp b/src/meta/test/ProcessorTest.cpp index ddf41189f49..174cb969abe 100644 --- a/src/meta/test/ProcessorTest.cpp +++ b/src/meta/test/ProcessorTest.cpp @@ -1301,7 +1301,9 @@ TEST(ProcessorTest, AlterTagTest) { for (auto i = 0; i < 2; i++) { cpp2::ColumnDef column; column.name = folly::stringPrintf("tag_0_col_%d", i); - column.type.type_ref() = i < 1 ? PropertyType::BOOL : PropertyType::DOUBLE; + // Column 0 is type int64 and is only allowed to chagne to int64. + // Column 1 is type fixed string with maximal length, so is only allowed to change to string. + column.type.type_ref() = i < 1 ? PropertyType::INT64 : PropertyType::STRING; (*changeSch.columns_ref()).emplace_back(std::move(column)); } cpp2::Schema dropSch; @@ -1351,7 +1353,7 @@ TEST(ProcessorTest, AlterTagTest) { cpp2::ColumnDef column; column.name = "tag_0_col_1"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::STRING; cols.emplace_back(std::move(column)); column.name = "tag_0_col_10"; @@ -1422,7 +1424,7 @@ TEST(ProcessorTest, AlterTagTest) { cpp2::ColumnDef column; column.name = "tag_0_col_1"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::STRING; cols.emplace_back(std::move(column)); column.name = "tag_0_col_10"; @@ -1473,7 +1475,7 @@ TEST(ProcessorTest, AlterTagTest) { cpp2::AlterTagReq req; cpp2::SchemaProp schemaProp; schemaProp.ttl_duration_ref() = 100; - schemaProp.ttl_col_ref() = "tag_0_col_11"; + schemaProp.ttl_col_ref() = "tag_0_col_11"; // Type string is not allowed to set ttl req.space_id_ref() = 1; req.tag_name_ref() = "tag_0"; @@ -1536,7 +1538,7 @@ TEST(ProcessorTest, AlterTagTest) { cpp2::ColumnDef column; column.name = "tag_0_col_1"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::STRING; cols.emplace_back(std::move(column)); column.name = "tag_0_col_11"; @@ -1646,7 +1648,7 @@ TEST(ProcessorTest, AlterTagTest) { auto resp = std::move(f).get(); ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code()); } - // Add col with out of range of fixed string + // Add col of fixed string { cpp2::AlterTagReq req; std::vector items; @@ -1697,6 +1699,96 @@ TEST(ProcessorTest, AlterTagTest) { } ASSERT_TRUE(expected); } + + // Verify illegal type conversion from string to int + { + cpp2::AlterTagReq req; + std::vector items; + cpp2::Schema changeSch; + cpp2::ColumnDef column; + column.name = "tag_0_col_1"; + column.type.type_ref() = PropertyType::INT64; + (*changeSch.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::CHANGE; + items.back().schema_ref() = std::move(changeSch); + req.space_id_ref() = 1; + req.tag_name_ref() = "tag_0"; + req.tag_items_ref() = items; + auto* processor = AlterTagProcessor::instance(kv.get()); + auto f = processor->getFuture(); + processor->process(req); + auto resp = std::move(f).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::E_UNSUPPORTED, resp.get_code()); + } + + // Verify illegal type conversion from int to string + { + // add a int column first + cpp2::AlterTagReq req; + std::vector items; + cpp2::Schema schema; + cpp2::ColumnDef column; + column.name = "add_col_int32_type"; + column.type.type_ref() = PropertyType::INT32; + (*schema.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::ADD; + items.back().schema_ref() = std::move(schema); + req.space_id_ref() = 1; + req.tag_name_ref() = "tag_0"; + req.tag_items_ref() = items; + auto* processor = AlterTagProcessor::instance(kv.get()); + auto f = processor->getFuture(); + processor->process(req); + auto resp = std::move(f).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); + + // try to convert the type + cpp2::Schema changeSch; + items.clear(); + column.name = "add_col_int32_type"; + column.type.type_ref() = PropertyType::STRING; + (*changeSch.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::CHANGE; + items.back().schema_ref() = std::move(changeSch); + req.space_id_ref() = 1; + req.tag_name_ref() = "tag_0"; + req.tag_items_ref() = items; + auto* changeSchProcessor = AlterTagProcessor::instance(kv.get()); + auto changeSchF = changeSchProcessor->getFuture(); + changeSchProcessor->process(req); + resp = std::move(changeSchF).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::E_UNSUPPORTED, resp.get_code()); + } + + // Verify illegal type conversion from wider fixed string to thinner fixed string + { + cpp2::AlterTagReq req; + std::vector items; + cpp2::Schema changeSch; + cpp2::ColumnDef column; + column.name = "add_col_fixed_string_type"; + column.type.type_ref() = PropertyType::FIXED_STRING; + column.type.type_length_ref() = 4; + (*changeSch.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::CHANGE; + items.back().schema_ref() = std::move(changeSch); + req.space_id_ref() = 1; + req.tag_name_ref() = "tag_0"; + req.tag_items_ref() = items; + auto* processor = AlterTagProcessor::instance(kv.get()); + auto f = processor->getFuture(); + processor->process(req); + auto resp = std::move(f).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::E_UNSUPPORTED, resp.get_code()); + } } TEST(ProcessorTest, AlterEdgeTest) { @@ -1751,7 +1843,10 @@ TEST(ProcessorTest, AlterEdgeTest) { for (int32_t i = 0; i < 2; i++) { cpp2::ColumnDef column; column.name = folly::stringPrintf("edge_0_col_%d", i); - column.type.type_ref() = i < 1 ? PropertyType::INT64 : PropertyType::STRING; + column.type.type_ref() = i < 1 ? PropertyType::INT64 : PropertyType::FIXED_STRING; + if (i == 1) { + column.type.type_length_ref() = MAX_INDEX_TYPE_LENGTH; + } (*addSch.columns_ref()).emplace_back(std::move(column)); } @@ -1781,7 +1876,7 @@ TEST(ProcessorTest, AlterEdgeTest) { for (auto i = 0; i < 2; i++) { cpp2::ColumnDef column; column.name = folly::stringPrintf("edge_%d_col_%d", 0, i); - column.type.type_ref() = i < 1 ? PropertyType::BOOL : PropertyType::DOUBLE; + column.type.type_ref() = i < 1 ? PropertyType::INT64 : PropertyType::STRING; (*changeSch.columns_ref()).emplace_back(std::move(column)); } cpp2::Schema dropSch; @@ -1840,7 +1935,7 @@ TEST(ProcessorTest, AlterEdgeTest) { cpp2::ColumnDef column; column.name = "edge_0_col_1"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::STRING; cols.emplace_back(std::move(column)); column.name = "edge_0_col_10"; @@ -1917,7 +2012,7 @@ TEST(ProcessorTest, AlterEdgeTest) { cpp2::ColumnDef column; column.name = "edge_0_col_1"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::STRING; cols.emplace_back(std::move(column)); column.name = "edge_0_col_10"; @@ -2032,7 +2127,7 @@ TEST(ProcessorTest, AlterEdgeTest) { cpp2::ColumnDef column; column.name = "edge_0_col_1"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::STRING; cols.emplace_back(std::move(column)); column.name = "edge_0_col_11"; @@ -2145,7 +2240,7 @@ TEST(ProcessorTest, AlterEdgeTest) { auto resp = std::move(f).get(); ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code()); } - // Add col with out of range of fixed string + // Add col of fixed string { cpp2::AlterEdgeReq req; std::vector items; @@ -2196,6 +2291,96 @@ TEST(ProcessorTest, AlterEdgeTest) { } ASSERT_TRUE(expected); } + + // Verify illegal type conversion from string to int + { + cpp2::AlterEdgeReq req; + std::vector items; + cpp2::Schema changeSch; + cpp2::ColumnDef column; + column.name = "edge_0_col_1"; + column.type.type_ref() = PropertyType::INT64; + (*changeSch.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::CHANGE; + items.back().schema_ref() = std::move(changeSch); + req.space_id_ref() = 1; + req.edge_name_ref() = "edge_0"; + req.edge_items_ref() = items; + auto* processor = AlterEdgeProcessor::instance(kv.get()); + auto f = processor->getFuture(); + processor->process(req); + auto resp = std::move(f).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::E_UNSUPPORTED, resp.get_code()); + } + + // Verify illegal type conversion from int to string + { + // add a int column first + cpp2::AlterEdgeReq req; + std::vector items; + cpp2::Schema schema; + cpp2::ColumnDef column; + column.name = "add_col_int32_type"; + column.type.type_ref() = PropertyType::INT32; + (*schema.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::ADD; + items.back().schema_ref() = std::move(schema); + req.space_id_ref() = 1; + req.edge_name_ref() = "edge_0"; + req.edge_items_ref() = items; + auto* processor = AlterEdgeProcessor::instance(kv.get()); + auto f = processor->getFuture(); + processor->process(req); + auto resp = std::move(f).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); + + // try to convert the type + cpp2::Schema changeSch; + items.clear(); + column.name = "add_col_int32_type"; + column.type.type_ref() = PropertyType::STRING; + (*changeSch.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::CHANGE; + items.back().schema_ref() = std::move(changeSch); + req.space_id_ref() = 1; + req.edge_name_ref() = "edge_0"; + req.edge_items_ref() = items; + auto* changeSchProcessor = AlterEdgeProcessor::instance(kv.get()); + auto changeSchF = changeSchProcessor->getFuture(); + changeSchProcessor->process(req); + resp = std::move(changeSchF).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::E_UNSUPPORTED, resp.get_code()); + } + + // Verify illegal type conversion from wider fixed string to thinner fixed string + { + cpp2::AlterEdgeReq req; + std::vector items; + cpp2::Schema changeSch; + cpp2::ColumnDef column; + column.name = "add_col_fixed_string_type"; + column.type.type_ref() = PropertyType::FIXED_STRING; + column.type.type_length_ref() = 4; + (*changeSch.columns_ref()).emplace_back(std::move(column)); + + items.emplace_back(); + items.back().op_ref() = cpp2::AlterSchemaOp::CHANGE; + items.back().schema_ref() = std::move(changeSch); + req.space_id_ref() = 1; + req.edge_name_ref() = "edge_0"; + req.edge_items_ref() = items; + auto* processor = AlterEdgeProcessor::instance(kv.get()); + auto f = processor->getFuture(); + processor->process(req); + auto resp = std::move(f).get(); + ASSERT_EQ(nebula::cpp2::ErrorCode::E_UNSUPPORTED, resp.get_code()); + } } TEST(ProcessorTest, AlterTagForMoreThan256TimesTest) { @@ -2283,7 +2468,7 @@ TEST(ProcessorTest, AlterTagForMoreThan256TimesTest) { { for (auto i = 1; i <= times; i++) { auto col_name = folly::stringPrintf("tag_0_a_%d", i); - auto col_type = PropertyType::INT64; + auto col_type = PropertyType::INT32; alterTagFunc(cpp2::AlterSchemaOp::ADD, col_name, col_type); totalScheVer++; @@ -2301,7 +2486,7 @@ TEST(ProcessorTest, AlterTagForMoreThan256TimesTest) { { for (auto i = 3; i < times; i += 2) { auto col_name = expectedCols[i].get_name(); - auto new_col_type = PropertyType::BOOL; + auto new_col_type = PropertyType::INT64; expectedCols[i].type.type_ref() = new_col_type; alterTagFunc(cpp2::AlterSchemaOp::CHANGE, col_name, new_col_type); totalScheVer++; @@ -2410,7 +2595,7 @@ TEST(ProcessorTest, AlterEdgeForMoreThan256TimesTest) { { for (auto i = 1; i <= times; i++) { auto col_name = folly::stringPrintf("edge_0_a_%d", i); - auto col_type = PropertyType::INT64; + auto col_type = PropertyType::INT32; alterEdgeFunc(cpp2::AlterSchemaOp::ADD, col_name, col_type); totalScheVer++; @@ -2428,7 +2613,7 @@ TEST(ProcessorTest, AlterEdgeForMoreThan256TimesTest) { { for (auto i = 3; i < times; i += 2) { auto col_name = expectedCols[i].get_name(); - auto new_col_type = PropertyType::BOOL; + auto new_col_type = PropertyType::INT64; expectedCols[i].type.type_ref() = new_col_type; alterEdgeFunc(cpp2::AlterSchemaOp::CHANGE, col_name, new_col_type); totalScheVer++; From 7b44fe561078cfd7d4544c7488b300cc1918dc77 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Fri, 23 Dec 2022 10:59:03 +0800 Subject: [PATCH 03/17] change to warning level --- src/meta/MetaServiceUtils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/meta/MetaServiceUtils.cpp b/src/meta/MetaServiceUtils.cpp index a5a13502e8a..f54a9c6c08b 100644 --- a/src/meta/MetaServiceUtils.cpp +++ b/src/meta/MetaServiceUtils.cpp @@ -97,10 +97,10 @@ nebula::cpp2::ErrorCode MetaServiceUtils::alterColumnDefs(std::vectorget_type(), col.get_type())) { - LOG(INFO) << "Update colume type " << colName << " from " - << apache::thrift::util::enumNameSafe(it->get_type().get_type()) << " to " - << apache::thrift::util::enumNameSafe(col.get_type().get_type()) - << " is not allowed!"; + LOG(WARNING) << "Update colume type " << colName << " from " + << apache::thrift::util::enumNameSafe(it->get_type().get_type()) << " to " + << apache::thrift::util::enumNameSafe(col.get_type().get_type()) + << " is not allowed!"; return nebula::cpp2::ErrorCode::E_UNSUPPORTED; } *it = col; From c314b984866e55ce617807ab22883613642ad4e8 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Fri, 23 Dec 2022 12:27:37 +0800 Subject: [PATCH 04/17] handle unknown type --- src/meta/MetaServiceUtils.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/meta/MetaServiceUtils.cpp b/src/meta/MetaServiceUtils.cpp index f54a9c6c08b..32abe693676 100644 --- a/src/meta/MetaServiceUtils.cpp +++ b/src/meta/MetaServiceUtils.cpp @@ -39,8 +39,11 @@ bool isLegalTypeConversion(cpp2::ColumnTypeDef from, cpp2::ColumnTypeDef to) { from.get_type() != nebula::cpp2::PropertyType::FIXED_STRING) { return true; } - - // fixed string can be converted to string or larger fixed string + // For unset type, always return true + if (from.get_type() == nebula::cpp2::PropertyType::UNKNOWN) { + return true; + } + // fixed string can be converted to string or wider fixed string if (from.get_type() == nebula::cpp2::PropertyType::FIXED_STRING) { if (to.get_type() == nebula::cpp2::PropertyType::STRING) { return true; From 4b529b8c66eaf38c8c4146fcdd3c89662d69e036 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:08:22 +0800 Subject: [PATCH 05/17] fix tck --- tests/query/stateless/test_schema.py | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/query/stateless/test_schema.py b/tests/query/stateless/test_schema.py index 676de55f4f5..7056635ff03 100644 --- a/tests/query/stateless/test_schema.py +++ b/tests/query/stateless/test_schema.py @@ -135,16 +135,12 @@ def test_alter_tag_succeed(self): ['age', 'string', 'YES', T_EMPTY, T_EMPTY]] self.check_result(resp, expect) - # alter change - resp = self.execute('ALTER TAG student change (age int)') - self.check_resp_succeeded(resp) - resp = self.execute('DESC TAG student') self.check_resp_succeeded(resp) expect = [['name', 'string', 'YES', T_EMPTY, T_EMPTY], ['email', 'string', 'YES', T_EMPTY, T_EMPTY], ['birthday', 'timestamp', 'YES', T_EMPTY, T_EMPTY], - ['age', 'int64', 'YES', T_EMPTY, T_EMPTY]] + ['age', 'string', 'YES', T_EMPTY, T_EMPTY]] self.check_result(resp, expect) def test_alter_tag_failed(self): @@ -169,6 +165,13 @@ def test_alter_tag_failed(self): except Exception as x: print('failed', x) + # alter change + try: + resp = self.execute('ALTER TAG student change (age int)') + self.check_resp_failed(resp) + except Exception as x: + print('failed', x) + def test_create_edge_succeed(self): # create edge without prop resp = self.execute('CREATE EDGE EDGE_empty()') @@ -277,16 +280,12 @@ def test_alter_edge_succeed(self): ['email', 'string', 'YES', T_EMPTY, T_EMPTY], ['start_year', 'string', 'YES', T_EMPTY, T_EMPTY]] self.check_result(resp, expect) - - # alter change - resp = self.execute('ALTER EDGE relationship change (start_year int)') - self.check_resp_succeeded(resp) - + resp = self.execute('DESC EDGE relationship') self.check_resp_succeeded(resp) expect = [['name', 'string', 'YES', T_EMPTY, T_EMPTY], ['email', 'string', 'YES', T_EMPTY, T_EMPTY], - ['start_year', 'int64', 'YES', T_EMPTY, T_EMPTY]] + ['start_year', 'string', 'YES', T_EMPTY, T_EMPTY]] self.check_result(resp, expect) def test_alter_edge_failed(self): @@ -311,6 +310,14 @@ def test_alter_edge_failed(self): except Exception as x: print('failed', x) + # alter change + try: + resp = self.execute('ALTER EDGE relationship change (start_year int)') + self.check_resp_succeeded(resp) + except Exception as x: + print('failed', x) + + # Cover https://github.com/vesoft-inc/nebula/issues/1732 def test_cover_fix_negative_default_value(self): # Tag From 21576c26ec79254e6557dd50eaf1afc0e3de5904 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:48:40 +0800 Subject: [PATCH 06/17] change to log error --- src/meta/MetaServiceUtils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/meta/MetaServiceUtils.cpp b/src/meta/MetaServiceUtils.cpp index 32abe693676..3452739b07d 100644 --- a/src/meta/MetaServiceUtils.cpp +++ b/src/meta/MetaServiceUtils.cpp @@ -100,10 +100,10 @@ nebula::cpp2::ErrorCode MetaServiceUtils::alterColumnDefs(std::vectorget_type(), col.get_type())) { - LOG(WARNING) << "Update colume type " << colName << " from " - << apache::thrift::util::enumNameSafe(it->get_type().get_type()) << " to " - << apache::thrift::util::enumNameSafe(col.get_type().get_type()) - << " is not allowed!"; + LOG(ERROR) << "Update colume type " << colName << " from " + << apache::thrift::util::enumNameSafe(it->get_type().get_type()) << " to " + << apache::thrift::util::enumNameSafe(col.get_type().get_type()) + << " is not allowed!"; return nebula::cpp2::ErrorCode::E_UNSUPPORTED; } *it = col; From bceb3d283cffefe9124feaff6d1800c42466a705 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Sun, 25 Dec 2022 09:12:14 +0800 Subject: [PATCH 07/17] update test to look better fix tck --- src/meta/test/ProcessorTest.cpp | 4 +-- tests/tck/features/ttl/TTL.feature | 56 ++++++++++++++++++------------ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/meta/test/ProcessorTest.cpp b/src/meta/test/ProcessorTest.cpp index 174cb969abe..faafcff2530 100644 --- a/src/meta/test/ProcessorTest.cpp +++ b/src/meta/test/ProcessorTest.cpp @@ -1454,7 +1454,7 @@ TEST(ProcessorTest, AlterTagTest) { cpp2::Schema changeSch; cpp2::ColumnDef column; column.name = "tag_0_col_10"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::INT64; (*changeSch.columns_ref()).emplace_back(std::move(column)); items.emplace_back(); @@ -2042,7 +2042,7 @@ TEST(ProcessorTest, AlterEdgeTest) { cpp2::Schema changeSch; cpp2::ColumnDef column; column.name = "edge_0_col_10"; - column.type.type_ref() = PropertyType::DOUBLE; + column.type.type_ref() = PropertyType::INT64; (*changeSch.columns_ref()).emplace_back(std::move(column)); items.emplace_back(); diff --git a/tests/tck/features/ttl/TTL.feature b/tests/tck/features/ttl/TTL.feature index 2aca8f1c872..ffdc308690d 100644 --- a/tests/tck/features/ttl/TTL.feature +++ b/tests/tck/features/ttl/TTL.feature @@ -112,7 +112,7 @@ Feature: TTLTest Then the execution should be successful When executing query: """ - CREATE TAG woman(name string, email string, age int, gender string, row_timestamp timestamp) ttl_duration = 0, ttl_col = "row_timestamp"; + CREATE TAG woman(name string, email string, age int32, gender string, row_timestamp timestamp) ttl_duration = 0, ttl_col = "row_timestamp"; """ Then the execution should be successful When executing query: @@ -126,7 +126,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ ALTER TAG woman ttl_duration = 100, ttl_col = "age"; @@ -138,10 +138,10 @@ Feature: TTLTest """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | When executing query: """ - ALTER TAG woman CHANGE (age string); + ALTER TAG woman CHANGE (age int64); """ Then a ExecutionError should be raised at runtime: When executing query: @@ -155,19 +155,24 @@ Feature: TTLTest """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ - ALTER TAG woman CHANGE (age string); + ALTER TAG woman CHANGE (age int64); """ Then the execution should be successful + When executing query: + """ + ALTER TAG woman CHANGE (age string); + """ + Then a ExecutionError should be raised at runtime: When executing query: """ SHOW CREATE TAG woman; """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` string NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ CREATE EDGE work(number string, start_time timestamp); @@ -222,7 +227,7 @@ Feature: TTLTest Then a ExecutionError should be raised at runtime: When executing query: """ - CREATE EDGE work2(name string, email string, age int, gender string, start_time timestamp) ttl_duration = 0, ttl_col = "start_time"; + CREATE EDGE work2(name string, email string, age int32, gender string, start_time timestamp) ttl_duration = 0, ttl_col = "start_time"; """ Then the execution should be successful When executing query: @@ -231,7 +236,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 0, ttl_col = "start_time"' | + | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 0, ttl_col = "start_time"' | When executing query: """ CREATE EDGE edge_only_ttl_col(name string, email string, age int, gender string, row_timestamp timestamp) ttl_col = "row_timestamp"; @@ -255,7 +260,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 50, ttl_col = "start_time"' | + | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 50, ttl_col = "start_time"' | When executing query: """ ALTER EDGE work2 ttl_col = "name"; @@ -272,7 +277,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 200, ttl_col = "start_time"' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 200, ttl_col = "start_time"' | When executing query: """ ALTER EDGE work2 Drop (start_time); @@ -284,7 +289,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ ALTER Edge work2 ttl_duration = 100, ttl_col = "age"; @@ -296,10 +301,10 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | When executing query: """ - ALTER EDGE work2 CHANGE (age string); + ALTER EDGE work2 CHANGE (age int64); """ Then a ExecutionError should be raised at runtime: When executing query: @@ -313,19 +318,24 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ - ALTER EDGE work2 CHANGE (age string); + ALTER EDGE work2 CHANGE (age int64); """ Then the execution should be successful + When executing query: + """ + ALTER EDGE work2 CHANGE (age string); + """ + Then a ExecutionError should be raised at runtime: When executing query: """ SHOW CREATE EDGE work2; """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` string NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ CREATE EDGE player(id int, name string, age int, address string, score float); @@ -340,27 +350,27 @@ Feature: TTLTest | "player" | 'CREATE EDGE `player` (\n `id` int64 NULL,\n `name` string NULL,\n `age` int64 NULL,\n `address` string NULL,\n `score` float NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ - ALTER EDGE player change(name int), drop(name); + ALTER EDGE player change(name string), drop(name); """ Then a SemanticError should be raised at runtime: Duplicate column name `name' When executing query: """ - ALTER EDGE player drop(name), change(name int); + ALTER EDGE player drop(name), change(name string); """ Then a SemanticError should be raised at runtime: Duplicate column name `name' When executing query: """ - ALTER EDGE player drop(name, name), change(address int); + ALTER EDGE player drop(name, name), change(address string); """ Then a SemanticError should be raised at runtime: Duplicate column name `name' When executing query: """ - ALTER EDGE player change(address int, address string); + ALTER EDGE player change(address string, address string); """ Then a SemanticError should be raised at runtime: Duplicate column name `address' When executing query: """ - ALTER EDGE player change(address int), drop(name); + ALTER EDGE player change(address string), drop(name); """ Then the execution should be successful When executing query: @@ -369,7 +379,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "player" | 'CREATE EDGE `player` (\n `id` int64 NULL,\n `age` int64 NULL,\n `address` int64 NULL,\n `score` float NULL\n) ttl_duration = 0, ttl_col = ""' | + | "player" | 'CREATE EDGE `player` (\n `id` int64 NULL,\n `age` int64 NULL,\n `address` string NULL,\n `score` float NULL\n) ttl_duration = 0, ttl_col = ""' | And drop the used space Scenario: TTLTest Datatest From e5e8752592e8aab8e159507dacd36aac35dc52f4 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Sun, 25 Dec 2022 09:26:38 +0800 Subject: [PATCH 08/17] lint --- tests/tck/features/ttl/TTL.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tck/features/ttl/TTL.feature b/tests/tck/features/ttl/TTL.feature index ffdc308690d..f986dff795e 100644 --- a/tests/tck/features/ttl/TTL.feature +++ b/tests/tck/features/ttl/TTL.feature @@ -172,7 +172,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ CREATE EDGE work(number string, start_time timestamp); @@ -335,7 +335,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ CREATE EDGE player(id int, name string, age int, address string, score float); @@ -378,7 +378,7 @@ Feature: TTLTest SHOW CREATE EDGE player; """ Then the result should be, in any order: - | Edge | Create Edge | + | Edge | Create Edge | | "player" | 'CREATE EDGE `player` (\n `id` int64 NULL,\n `age` int64 NULL,\n `address` string NULL,\n `score` float NULL\n) ttl_duration = 0, ttl_col = ""' | And drop the used space From 18d01fb78548cb763363b1b90861484ba1cf8cc6 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Sun, 25 Dec 2022 09:30:59 +0800 Subject: [PATCH 09/17] lint --- tests/tck/features/ttl/TTL.feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tck/features/ttl/TTL.feature b/tests/tck/features/ttl/TTL.feature index f986dff795e..63d828acf7d 100644 --- a/tests/tck/features/ttl/TTL.feature +++ b/tests/tck/features/ttl/TTL.feature @@ -171,8 +171,8 @@ Feature: TTLTest SHOW CREATE TAG woman; """ Then the result should be, in any order: - | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | Tag | Create Tag | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ CREATE EDGE work(number string, start_time timestamp); @@ -334,8 +334,8 @@ Feature: TTLTest SHOW CREATE EDGE work2; """ Then the result should be, in any order: - | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | Edge | Create Edge | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ CREATE EDGE player(id int, name string, age int, address string, score float); From 494dfac5886ff180b43a510daa5da2d22e609712 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Sun, 25 Dec 2022 10:22:58 +0800 Subject: [PATCH 10/17] change int32 to int64 in tck --- tests/tck/features/ttl/TTL.feature | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/tck/features/ttl/TTL.feature b/tests/tck/features/ttl/TTL.feature index 63d828acf7d..cb001053f3a 100644 --- a/tests/tck/features/ttl/TTL.feature +++ b/tests/tck/features/ttl/TTL.feature @@ -112,7 +112,7 @@ Feature: TTLTest Then the execution should be successful When executing query: """ - CREATE TAG woman(name string, email string, age int32, gender string, row_timestamp timestamp) ttl_duration = 0, ttl_col = "row_timestamp"; + CREATE TAG woman(name string, email string, age int, gender string, row_timestamp timestamp) ttl_duration = 0, ttl_col = "row_timestamp"; """ Then the execution should be successful When executing query: @@ -126,7 +126,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ ALTER TAG woman ttl_duration = 100, ttl_col = "age"; @@ -138,7 +138,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | When executing query: """ ALTER TAG woman CHANGE (age int64); @@ -155,7 +155,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Tag | Create Tag | - | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "woman" | 'CREATE TAG `woman` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ ALTER TAG woman CHANGE (age int64); @@ -227,7 +227,7 @@ Feature: TTLTest Then a ExecutionError should be raised at runtime: When executing query: """ - CREATE EDGE work2(name string, email string, age int32, gender string, start_time timestamp) ttl_duration = 0, ttl_col = "start_time"; + CREATE EDGE work2(name string, email string, age int, gender string, start_time timestamp) ttl_duration = 0, ttl_col = "start_time"; """ Then the execution should be successful When executing query: @@ -236,7 +236,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 0, ttl_col = "start_time"' | + | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 0, ttl_col = "start_time"' | When executing query: """ CREATE EDGE edge_only_ttl_col(name string, email string, age int, gender string, row_timestamp timestamp) ttl_col = "row_timestamp"; @@ -260,7 +260,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 50, ttl_col = "start_time"' | + | "work2" | 'CREATE EDGE `work2` (\n `name` string NULL,\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 50, ttl_col = "start_time"' | When executing query: """ ALTER EDGE work2 ttl_col = "name"; @@ -277,7 +277,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 200, ttl_col = "start_time"' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL,\n `start_time` timestamp NULL\n) ttl_duration = 200, ttl_col = "start_time"' | When executing query: """ ALTER EDGE work2 Drop (start_time); @@ -289,7 +289,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ ALTER Edge work2 ttl_duration = 100, ttl_col = "age"; @@ -301,7 +301,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 100, ttl_col = "age"' | When executing query: """ ALTER EDGE work2 CHANGE (age int64); @@ -318,7 +318,7 @@ Feature: TTLTest """ Then the result should be, in any order: | Edge | Create Edge | - | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int32 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` int64 NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | When executing query: """ ALTER EDGE work2 CHANGE (age int64); From 4c259707b921d6beb8d3f135dd945ec3053fdc91 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Sun, 25 Dec 2022 12:32:42 +0800 Subject: [PATCH 11/17] fix test_insert_vertex_and_edge_test_2 tck --- tests/tck/features/schema/Schema.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index 0f8c0bbb5d9..7d002b58484 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -124,7 +124,7 @@ Feature: Insert string vid of vertex and edge # alter tag When executing query: """ - ALTER TAG person ADD (col1 int, col2 string), CHANGE (age string), DROP (gender) + ALTER TAG person ADD (col1 int, col2 string), CHANGE (age int), DROP (gender) """ Then the execution should be successful # drop not exist prop From f3cadbabd0653d7e0d798e7a05ed8eaaa804d9c8 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Mon, 26 Dec 2022 04:00:30 +0800 Subject: [PATCH 12/17] fix tck --- tests/tck/features/schema/Schema.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index 7d002b58484..a250b67b84b 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -142,7 +142,7 @@ Feature: Insert string vid of vertex and edge | Field | Type | Null | Default | Comment | | "name" | "string" | "YES" | EMPTY | EMPTY | | "email" | "string" | "YES" | "NULL" | EMPTY | - | "age" | "string" | "YES" | EMPTY | EMPTY | + | "age" | "int64" | "YES" | EMPTY | EMPTY | | "row_timestamp" | "timestamp" | "YES" | 2020 | EMPTY | | "col1" | "int64" | "YES" | EMPTY | EMPTY | | "col2" | "string" | "YES" | EMPTY | EMPTY | From b12d547eec865ed618aa2f1e2375ff63a39f55a9 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Wed, 28 Dec 2022 04:03:37 +0800 Subject: [PATCH 13/17] fix tck --- tests/tck/features/schema/Schema.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index a250b67b84b..34dc1af8df4 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -331,7 +331,7 @@ Feature: Insert string vid of vertex and edge # alter edge When executing query: """ - ALTER EDGE education ADD (col1 int, col2 string), CHANGE (school int), DROP (id, time_) + ALTER EDGE education ADD (col1 int, col2 string), CHANGE (school string), DROP (id, time_) """ Then the execution should be successful # drop not exist prop, failed From 5370f9e2585bdafe4e35fe734b0835b5b25ad7db Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Wed, 28 Dec 2022 06:04:19 +0800 Subject: [PATCH 14/17] fix tck --- tests/tck/features/schema/Schema.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index 34dc1af8df4..2ec3bb0faca 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -347,7 +347,7 @@ Feature: Insert string vid of vertex and edge """ Then the result should be, in any order: | Field | Type | Null | Default | Comment | - | "school" | "int64" | "YES" | EMPTY | EMPTY | + | "school" | "string" | "YES" | EMPTY | EMPTY | | "col1" | "int64" | "YES" | EMPTY | EMPTY | | "col2" | "string" | "YES" | EMPTY | EMPTY | # with negative DEFAULT value From a9bb5eabbac36f8cbdf8c1f1ebbbe46506f370ae Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Wed, 28 Dec 2022 06:25:15 +0800 Subject: [PATCH 15/17] format --- tests/tck/features/schema/Schema.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index 2ec3bb0faca..33bb98993b4 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -347,7 +347,7 @@ Feature: Insert string vid of vertex and edge """ Then the result should be, in any order: | Field | Type | Null | Default | Comment | - | "school" | "string" | "YES" | EMPTY | EMPTY | + | "school" | "string" | "YES" | EMPTY | EMPTY | | "col1" | "int64" | "YES" | EMPTY | EMPTY | | "col2" | "string" | "YES" | EMPTY | EMPTY | # with negative DEFAULT value From 7fac0a12d9119cfad4ee03477b77daf0e6a373a9 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Wed, 28 Dec 2022 07:16:27 +0800 Subject: [PATCH 16/17] fix tck --- tests/tck/features/schema/Schema.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index 33bb98993b4..403cd1f7fc3 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -695,7 +695,7 @@ Feature: Insert string vid of vertex and edge # test alter tag with wrong type default value of time when change When executing query: """ - ALTER TAG tag_not_null_default1 CHANGE (name FIXED_STRING(10) DEFAULT 10) + ALTER TAG tag_not_null_default1 CHANGE (name string DEFAULT 10) """ Then a ExecutionError should be raised at runtime: Invalid param! # test alter edge with wrong type default value of string when add From 62cdd6b466cded06be269eb6bec947089d9c1b69 Mon Sep 17 00:00:00 2001 From: Hao Wen <19355821+wenhaocs@users.noreply.github.com> Date: Wed, 28 Dec 2022 07:41:44 +0800 Subject: [PATCH 17/17] fix tck --- tests/tck/features/schema/Schema.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index 403cd1f7fc3..49f0032ba42 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -752,7 +752,7 @@ Feature: Insert string vid of vertex and edge # test alter tag with wrong type default value of time when change When executing query: """ - ALTER EDGE edge_not_null_default1 CHANGE (name FIXED_STRING(10) DEFAULT 10) + ALTER EDGE edge_not_null_default1 CHANGE (name string DEFAULT 10) """ Then a ExecutionError should be raised at runtime: Invalid param! # chinese tag without quote mark