@@ -687,6 +687,83 @@ TEST_F(IndexTest, EdgeIndexTTL) {
687
687
}
688
688
}
689
689
690
+ TEST_F (IndexTest, AlterTag) {
691
+ auto client = gEnv ->getClient ();
692
+ ASSERT_NE (nullptr , client);
693
+ {
694
+ cpp2::ExecutionResponse resp;
695
+ std::string query = " CREATE SPACE tag_index_space(partition_num=1, replica_factor=1)" ;
696
+ auto code = client->execute (query, resp);
697
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
698
+
699
+ query = " USE tag_index_space" ;
700
+ code = client->execute (query, resp);
701
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
702
+
703
+ query = " CREATE TAG person(name string, age int, gender string, email string)" ;
704
+ code = client->execute (query, resp);
705
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
706
+ }
707
+ sleep (FLAGS_heartbeat_interval_secs + 1 );
708
+ // Single Tag Single Field
709
+ {
710
+ cpp2::ExecutionResponse resp;
711
+ std::string query = " CREATE TAG INDEX single_person_index ON person(name)" ;
712
+ auto code = client->execute (query, resp);
713
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
714
+ }
715
+ sleep (FLAGS_heartbeat_interval_secs + 1 );
716
+ {
717
+ cpp2::ExecutionResponse resp;
718
+ auto query = " INSERT VERTEX person(name, age, gender, email) VALUES "
719
+ " 100: (\" Tim\" , 18, \" M\" , \" [email protected] \" )" ;
720
+ auto code = client->execute (query, resp);
721
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
722
+ }
723
+ {
724
+ cpp2::ExecutionResponse resp;
725
+ auto query = " ALTER TAG person ADD (col1 int)" ;
726
+ auto code = client->execute (query, resp);
727
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
728
+ }
729
+ sleep (FLAGS_heartbeat_interval_secs + 1 );
730
+ // Single Tag Single Field
731
+ {
732
+ cpp2::ExecutionResponse resp;
733
+ std::string query = " CREATE TAG INDEX single_person_index2 ON person(col1)" ;
734
+ auto code = client->execute (query, resp);
735
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
736
+ }
737
+ sleep (FLAGS_heartbeat_interval_secs + 1 );
738
+ {
739
+ cpp2::ExecutionResponse resp;
740
+ auto query = " INSERT VERTEX person(name, age, gender, email, col1) VALUES "
741
+ " 100:(\" Tim\" , 18, \" M\" , \" [email protected] \" , 5)" ;
742
+ auto code = client->execute (query, resp);
743
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
744
+ }
745
+ {
746
+ cpp2::ExecutionResponse resp;
747
+ auto query = " LOOKUP ON person WHERE person.col1 == 5 YIELD person.col1, person.name" ;
748
+ auto code = client->execute (query, resp);
749
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
750
+ std::vector<std::tuple<VertexID, int64_t , std::string>> expected = {
751
+ {100 , 5 , " Tim" },
752
+ };
753
+ ASSERT_TRUE (verifyResult (resp, expected));
754
+ }
755
+ {
756
+ cpp2::ExecutionResponse resp;
757
+ auto query = " LOOKUP ON person where person.name == \" Tim\" YIELD person.name, person.col1" ;
758
+ auto code = client->execute (query, resp);
759
+ ASSERT_EQ (cpp2::ErrorCode::SUCCEEDED, code);
760
+ std::vector<std::tuple<VertexID, std::string, int64_t >> expected = {
761
+ {100 , " Tim" , 5 },
762
+ };
763
+ ASSERT_TRUE (verifyResult (resp, expected));
764
+ }
765
+ }
766
+
690
767
} // namespace graph
691
768
} // namespace nebula
692
769
0 commit comments