Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the ttl grammar for label the ttl_col , alter grammer. #1874

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/graph/ShowExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,19 +635,18 @@ void ShowExecutor::showCreateTag() {
buf.resize(buf.size() -2);
buf += "\n";
}
buf += ") ";
buf += ")";
nebula::cpp2::SchemaProp prop = schema.schema_prop;
buf += "ttl_duration = ";
bool seprate = false;
if (prop.get_ttl_duration()) {
seprate = true;
buf += " ttl_duration = ";
buf += folly::to<std::string>(*prop.get_ttl_duration());
} else {
buf += "0";
}
buf += ", ttl_col = ";
if (prop.get_ttl_col() && !(prop.get_ttl_col()->empty())) {
if (seprate) buf += ",";
buf += " ttl_col = ";
buf += *prop.get_ttl_col();
} else {
buf += "\"\"";
}

row[1].set_str(buf);
Expand Down Expand Up @@ -733,19 +732,18 @@ void ShowExecutor::showCreateEdge() {
buf.resize(buf.size() -2);
buf += "\n";
}
buf += ") ";
buf += ")";
nebula::cpp2::SchemaProp prop = schema.schema_prop;
buf += "ttl_duration = ";
bool seprate = false;
if (prop.get_ttl_duration()) {
buf += " ttl_duration = ";
buf += folly::to<std::string>(*prop.get_ttl_duration());
} else {
buf += "0";
seprate = true;
}
buf += ", ttl_col = ";
if (prop.get_ttl_col() && !(prop.get_ttl_col()->empty())) {
if (seprate) buf += ",";
buf += " ttl_col = ";
buf += *prop.get_ttl_col();
} else {
buf += "\"\"";
}

row[1].set_str(buf);
Expand Down
24 changes: 12 additions & 12 deletions src/graph/test/IndexTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ TEST_F(IndexTest, TagIndexTTL) {
// Alter tag add ttl property on index col, failed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER TAG person_ttl ttl_duration = 100, ttl_col = \"age\"";
std::string query = "ALTER TAG person_ttl ttl_duration = 100, ttl_col = age";
auto code = client->execute(query, resp);
ASSERT_NE(cpp2::ErrorCode::SUCCEEDED, code);
}
// Alter tag add ttl property on not index col, failed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER TAG person_ttl ttl_duration = 100, ttl_col = \"gender\"";
std::string query = "ALTER TAG person_ttl ttl_duration = 100, ttl_col = gender";
auto code = client->execute(query, resp);
ASSERT_NE(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand All @@ -425,14 +425,14 @@ TEST_F(IndexTest, TagIndexTTL) {
// Alter tag add ttl property on index col, succeed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER TAG person_ttl ttl_duration = 100, ttl_col = \"age\"";
std::string query = "ALTER TAG person_ttl CHANGE ttl_duration = 100, ttl_col = age";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
// Alter tag add ttl property on not index col, succeed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER TAG person_ttl ttl_duration = 100, ttl_col = \"gender\"";
std::string query = "ALTER TAG person_ttl CHANGE ttl_duration = 100, ttl_col = gender";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand All @@ -453,7 +453,7 @@ TEST_F(IndexTest, TagIndexTTL) {
// Drop ttl propery
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER TAG person_ttl ttl_col = \"\"";
std::string query = "ALTER TAG person_ttl DROP TTL";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand All @@ -474,7 +474,7 @@ TEST_F(IndexTest, TagIndexTTL) {
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE TAG person_ttl_2(name string, age int, gender string)"
" ttl_duration = 200, ttl_col = \"age\"";
" ttl_duration = 200, ttl_col = age";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand Down Expand Up @@ -548,14 +548,14 @@ TEST_F(IndexTest, EdgeIndexTTL) {
// Alter edge add ttl property on index col, failed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER edge friend_ttl ttl_duration = 100, ttl_col = \"start_time\"";
std::string query = "ALTER edge friend_ttl ttl_duration = 100, ttl_col = start_time";
auto code = client->execute(query, resp);
ASSERT_NE(cpp2::ErrorCode::SUCCEEDED, code);
}
// Alter edge add ttl property on not index col, failed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER edge friend_ttl ttl_duration = 100, ttl_col = \"degree\"";
std::string query = "ALTER edge friend_ttl ttl_duration = 100, ttl_col = degree";
auto code = client->execute(query, resp);
ASSERT_NE(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand All @@ -569,14 +569,14 @@ TEST_F(IndexTest, EdgeIndexTTL) {
// Alter edge add ttl property on index col, succeed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER edge friend_ttl ttl_duration = 100, ttl_col = \"start_time\"";
std::string query = "ALTER edge friend_ttl CHANGE ttl_duration = 100, ttl_col = start_time";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
// Alter edge add ttl property on not index col, succeed
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER edge friend_ttl ttl_duration = 100, ttl_col = \"degree\"";
std::string query = "ALTER edge friend_ttl CHANGE ttl_duration = 100, ttl_col = degree";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand All @@ -597,7 +597,7 @@ TEST_F(IndexTest, EdgeIndexTTL) {
// Drop ttl propery
{
cpp2::ExecutionResponse resp;
std::string query = "ALTER EDGE friend_ttl ttl_col = \"\"";
std::string query = "ALTER EDGE friend_ttl DROP TTL";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand All @@ -619,7 +619,7 @@ TEST_F(IndexTest, EdgeIndexTTL) {
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE EDGE friend_ttl_2(degree int, start_time int)"
" ttl_duration = 200, ttl_col = \"start_time\"";
" ttl_duration = 200, ttl_col = start_time";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
Expand Down
Loading