@@ -910,6 +910,78 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) {
910
910
}
911
911
}
912
912
913
+ Y_UNIT_TEST (IndexPartitioningIsPersisted) {
914
+ TTestBasicRuntime runtime;
915
+ TTestEnv env (runtime);
916
+ ui64 txId = 100 ;
917
+
918
+ TestCreateTable (runtime, ++txId, " /MyRoot" , R"(
919
+ Name: "Table"
920
+ Columns { Name: "key" Type: "Uint64" }
921
+ Columns { Name: "value" Type: "Utf8" }
922
+ KeyColumnNames: [ "key" ]
923
+ )" );
924
+ env.TestWaitNotification (runtime, txId);
925
+
926
+ Ydb::Table::GlobalIndexSettings settings;
927
+ UNIT_ASSERT (google::protobuf::TextFormat::ParseFromString (R"(
928
+ partition_at_keys {
929
+ split_points {
930
+ type { tuple_type { elements { optional_type { item { type_id: UTF8 } } } } }
931
+ value { items { text_value: "alice" } }
932
+ }
933
+ split_points {
934
+ type { tuple_type { elements { optional_type { item { type_id: UTF8 } } } } }
935
+ value { items { text_value: "bob" } }
936
+ }
937
+ }
938
+ partitioning_settings {
939
+ min_partitions_count: 3
940
+ max_partitions_count: 3
941
+ }
942
+ )" , &settings));
943
+
944
+ TBlockEvents<TEvSchemeShard::TEvModifySchemeTransaction> indexCreationBlocker (runtime, [](const auto & ev) {
945
+ const auto & modifyScheme = ev->Get ()->Record .GetTransaction (0 );
946
+ return modifyScheme.GetOperationType () == NKikimrSchemeOp::ESchemeOpCreateIndexBuild;
947
+ });
948
+
949
+ const ui64 buildIndexTx = ++txId;
950
+ TestBuildIndex (runtime, buildIndexTx, TTestTxConfig::SchemeShard, " /MyRoot" , " /MyRoot/Table" , TBuildIndexConfig{
951
+ " Index" , NKikimrSchemeOp::EIndexTypeGlobal, { " value" }, {},
952
+ { NYdb::NTable::TGlobalIndexSettings::FromProto (settings) }
953
+ });
954
+
955
+ RebootTablet (runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor ());
956
+
957
+ indexCreationBlocker.Stop ().Unblock ();
958
+ env.TestWaitNotification (runtime, buildIndexTx);
959
+
960
+ auto buildIndexOperation = TestGetBuildIndex (runtime, TTestTxConfig::SchemeShard, " /MyRoot" , buildIndexTx);
961
+ UNIT_ASSERT_VALUES_EQUAL_C (
962
+ (int )buildIndexOperation.GetIndexBuild ().GetState (), (int )Ydb::Table::IndexBuildState::STATE_DONE,
963
+ buildIndexOperation.DebugString ()
964
+ );
965
+
966
+ TestDescribeResult (DescribePath (runtime, " /MyRoot/Table" ), {
967
+ NLs::IsTable,
968
+ NLs::IndexesCount (1 )
969
+ });
970
+
971
+ TestDescribeResult (DescribePrivatePath (runtime, " /MyRoot/Table/Index" ), {
972
+ NLs::PathExist,
973
+ NLs::IndexState (NKikimrSchemeOp::EIndexState::EIndexStateReady)
974
+ });
975
+
976
+ TestDescribeResult (DescribePrivatePath (runtime, " /MyRoot/Table/Index/indexImplTable" , true , true ), {
977
+ NLs::IsTable,
978
+ NLs::PartitionCount (3 ),
979
+ NLs::MinPartitionsCountEqual (3 ),
980
+ NLs::MaxPartitionsCountEqual (3 ),
981
+ NLs::PartitionKeys ({" alice" , " bob" , " " })
982
+ });
983
+ }
984
+
913
985
Y_UNIT_TEST (DropIndex) {
914
986
TTestBasicRuntime runtime;
915
987
TTestEnv env (runtime);
0 commit comments