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

replace STRING to name_label for zone's name #3780

Merged
merged 2 commits into from
Jan 29, 2022
Merged
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
24 changes: 12 additions & 12 deletions src/parser/MaintainSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,39 +426,39 @@ std::string MergeZoneSentence::toString() const {
buf.reserve(128);
buf += "MERGE ZONE ";
buf += zoneNames_->toString();
buf += " INTO \"";
buf += " INTO `";
buf += *zoneName_;
buf += "\"";
buf += "`";
return buf;
}

std::string DropZoneSentence::toString() const {
return folly::stringPrintf("DROP ZONE \"%s\"", zoneName_.get()->c_str());
return folly::stringPrintf("DROP ZONE `%s`", zoneName_.get()->c_str());
}

std::string DivideZoneSentence::toString() const {
std::string buf;
buf.reserve(128);
buf += "DIVIDE ZONE \"";
buf += "DIVIDE ZONE `";
buf += *zoneName_;
buf += "\" INTO ";
buf += "` INTO ";
buf += zoneItems_->toString();
return buf;
}

std::string RenameZoneSentence::toString() const {
std::string buf;
buf.reserve(128);
buf += "RENAME ZONE \"";
buf += "RENAME ZONE `";
buf += *originalZoneName_;
buf += "\" TO \"";
buf += "` TO `";
buf += *zoneName_;
buf += "\"";
buf += "`";
return buf;
}

std::string DescribeZoneSentence::toString() const {
return folly::stringPrintf("DESCRIBE ZONE \"%s\"", zoneName_.get()->c_str());
return folly::stringPrintf("DESCRIBE ZONE `%s`", zoneName_.get()->c_str());
}

std::string ShowZonesSentence::toString() const {
Expand All @@ -471,12 +471,12 @@ std::string AddHostsIntoZoneSentence::toString() const {
buf += "ADD HOSTS ";
buf += address_->toString();
if (isNew_) {
buf += " INTO NEW ZONE \"";
buf += " INTO NEW ZONE `";
} else {
buf += " INTO ZONE \"";
buf += " INTO ZONE `";
}
buf += *zoneName_;
buf += "\"";
buf += "`";
return buf;
}

Expand Down
8 changes: 4 additions & 4 deletions src/parser/Sentence.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ class ZoneNameList final {
std::string toString() const {
std::string buf;
for (const auto &zone : zones_) {
buf += "\"";
buf += "`";
buf += *zone;
buf += "\"";
buf += "`";
buf += ",";
}
if (!zones_.empty()) {
Expand All @@ -243,9 +243,9 @@ class ZoneItem final {

std::string toString() const {
std::string buf;
buf += "\"";
buf += "`";
buf += *zone_;
buf += "\"";
buf += "`";
buf += " (";
buf += hosts_->toString();
buf += ")";
Expand Down
22 changes: 11 additions & 11 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -2813,10 +2813,10 @@ add_hosts_sentence
: KW_ADD KW_HOSTS host_list {
$$ = new AddHostsSentence($3);
}
| KW_ADD KW_HOSTS host_list KW_INTO KW_ZONE STRING {
| KW_ADD KW_HOSTS host_list KW_INTO KW_ZONE name_label {
$$ = new AddHostsIntoZoneSentence($3, $6, false);
}
| KW_ADD KW_HOSTS host_list KW_INTO KW_NEW KW_ZONE STRING {
| KW_ADD KW_HOSTS host_list KW_INTO KW_NEW KW_ZONE name_label {
$$ = new AddHostsIntoZoneSentence($3, $7, true);
}
;
Expand All @@ -2829,19 +2829,19 @@ drop_hosts_sentence


merge_zone_sentence
: KW_MERGE KW_ZONE zone_name_list KW_INTO STRING {
: KW_MERGE KW_ZONE zone_name_list KW_INTO name_label {
$$ = new MergeZoneSentence($3, $5);
}
;

drop_zone_sentence
: KW_DROP KW_ZONE STRING {
: KW_DROP KW_ZONE name_label {
$$ = new DropZoneSentence($3);
}
;

zone_item
: STRING L_PAREN host_list R_PAREN {
: name_label L_PAREN host_list R_PAREN {
$$ = new nebula::ZoneItem($1, $3);
}
;
Expand All @@ -2858,22 +2858,22 @@ zone_item_list
;

divide_zone_sentence
: KW_DIVIDE KW_ZONE STRING KW_INTO zone_item_list {
: KW_DIVIDE KW_ZONE name_label KW_INTO zone_item_list {
$$ = new DivideZoneSentence($3, $5);
}
;

rename_zone_sentence
: KW_RENAME KW_ZONE STRING KW_TO STRING {
: KW_RENAME KW_ZONE name_label KW_TO name_label {
$$ = new RenameZoneSentence($3, $5);
}
;

desc_zone_sentence
: KW_DESCRIBE KW_ZONE STRING {
: KW_DESCRIBE KW_ZONE name_label {
$$ = new DescribeZoneSentence($3);
}
| KW_DESC KW_ZONE STRING {
| KW_DESC KW_ZONE name_label {
$$ = new DescribeZoneSentence($3);
}
;
Expand Down Expand Up @@ -3495,11 +3495,11 @@ show_config_item
;

zone_name_list
: STRING {
: name_label {
$$ = new ZoneNameList();
$$->addZone($1);
}
| zone_name_list COMMA STRING {
| zone_name_list COMMA name_label {
$$ = $1;
$$->addZone($3);
}
Expand Down
62 changes: 31 additions & 31 deletions src/parser/test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,24 +231,24 @@ TEST_F(ParserTest, SpaceOperation) {
{
std::string query =
"CREATE SPACE default_space(partition_num=9, replica_factor=3) "
"ON \"zone_0\"";
"ON zone_0";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query =
"CREATE SPACE default_space(partition_num=9, replica_factor=3) "
"ON \"zone_0\",\"zone_1\",\"zone_2\"";
"ON zone_0,zone_1,zone_2";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "CREATE SPACE default_space ON \"zone_0\"";
std::string query = "CREATE SPACE default_space ON zone_0";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "CREATE SPACE default_space ON \"zone_0\",\"zone_1\",\"zone_2\"";
std::string query = "CREATE SPACE default_space ON `zone_0`,`zone_1`,`zone_2`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
Expand Down Expand Up @@ -2806,129 +2806,129 @@ TEST_F(ParserTest, Zone) {
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO ZONE \"zone_0\"";
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO ZONE `zone_0`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO NEW ZONE \"zone_0\"";
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO NEW ZONE `zone_0`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO ZONE \"default_zone_127.0.0.1_8988\"";
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO ZONE `default_zone_127.0.0.1_8988`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO NEW ZONE \"default_zone_127.0.0.1_8988\"";
std::string query = "ADD HOSTS 127.0.0.1:8989 INTO NEW ZONE `default_zone_127.0.0.1_8988`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD HOSTS 127.0.0.1:8988,127.0.0.1:8989 INTO ZONE \"zone_0\"";
std::string query = "ADD HOSTS 127.0.0.1:8988,127.0.0.1:8989 INTO ZONE `zone_0`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD HOSTS 127.0.0.1:8988,127.0.0.1:8989 INTO NEW ZONE \"zone_0\"";
std::string query = "ADD HOSTS 127.0.0.1:8988,127.0.0.1:8989 INTO NEW ZONE `zone_0`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query =
"ADD HOSTS 127.0.0.1:8988,127.0.0.1:8989 INTO ZONE"
" \"default_zone_127.0.0.1_8988\"";
" `default_zone_127.0.0.1_8988`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query =
"ADD HOSTS 127.0.0.1:8988,127.0.0.1:8989 INTO NEW ZONE"
" \"default_zone_127.0.0.1_8988\"";
" `default_zone_127.0.0.1_8988`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DESC ZONE \"default_zone_127.0.0.1_8988\"";
std::string query = "DESC ZONE `default_zone_127.0.0.1_8988`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DESC ZONE \"zone_0\"";
std::string query = "DESC ZONE `zone_0`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DESCRIBE ZONE \"zone_0\"";
std::string query = "DESCRIBE ZONE `zone_0`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DESCRIBE ZONE \"default_zone_127.0.0.1_8988\"";
std::string query = "DESCRIBE ZONE `default_zone_127.0.0.1_8988`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DROP ZONE \"zone_0\"";
std::string query = "DROP ZONE `zone_0`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DROP ZONE \"default_zone_127.0.0.1_8988\"";
std::string query = "DROP ZONE `default_zone_127.0.0.1_8988`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "MERGE ZONE \"zone_1\",\"zone_2\" INTO \"zone\"";
std::string query = "MERGE ZONE `zone_1`,`zone_2` INTO `zone`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "MERGE ZONE \"zone_1\",\"zone_2\" INTO \"zone_1\"";
std::string query = "MERGE ZONE `zone_1`,`zone_2` INTO `zone_1`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query =
"MERGE ZONE \"default_zone_127.0.0.1_8988\",\"default_zone_127.0.0.1_8989\""
"INTO \"zone_1\"";
"MERGE ZONE `default_zone_127.0.0.1_8988`,`default_zone_127.0.0.1_8989`"
"INTO `zone_1`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query =
"MERGE ZONE \"default_zone_127.0.0.1_8988\",\"default_zone_127.0.0.1_8989\""
"INTO \"default_zone_127.0.0.1_8989\"";
"MERGE ZONE `default_zone_127.0.0.1_8988`,`default_zone_127.0.0.1_8989`"
"INTO `default_zone_127.0.0.1_8989`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "RENAME ZONE \"default_zone_127.0.0.1_8989\" TO \"new_name\"";
std::string query = "RENAME ZONE `default_zone_127.0.0.1_8989` TO `new_name`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "RENAME ZONE \"old_name\" TO \"new_name\"";
std::string query = "RENAME ZONE `old_name` TO `new_name`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "RENAME ZONE \"default_zone_127.0.0.1_8989\" TO \"new_name\"";
std::string query = "RENAME ZONE `default_zone_127.0.0.1_8989` TO `new_name`";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query =
"DIVIDE ZONE \"zone_0\" INTO \"z_1\" (127.0.0.1:8988) "
" \"z_2\" (127.0.0.1:8989)";
"DIVIDE ZONE zone_0 INTO `z_1` (127.0.0.1:8988) "
" `z_2` (127.0.0.1:8989)";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query =
"DIVIDE ZONE \"zone_0\" INTO \"z_1\" (127.0.0.1:8986,127.0.0.1:8987)"
" \"z_2\" (127.0.0.1:8988,127.0.0.1:8989)";
"DIVIDE ZONE `zone_0` INTO `z_1` (127.0.0.1:8986,127.0.0.1:8987)"
" `z_2` (127.0.0.1:8988,127.0.0.1:8989)";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/tck/features/admin/Hosts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Feature: Admin hosts
Then a SemanticError should be raised at runtime: space vid_type must be specified explicitly
When executing query:
"""
CREATE SPACE space_without_vid_type(partition_num=9, replica_factor=3) on "default_zone";
CREATE SPACE space_without_vid_type(partition_num=9, replica_factor=3) on default_zone;
"""
Then a SemanticError should be raised at runtime: Create space with zone is unsupported
When executing query:
"""
CREATE SPACE space_without_vid_type on "default_zone";
CREATE SPACE space_without_vid_type on default_zone;
"""
Then a SemanticError should be raised at runtime: Create space with zone is unsupported
When executing query:
Expand Down