@@ -934,6 +934,78 @@ Y_UNIT_TEST_SUITE(IndexBuildTest) {
934
934
}
935
935
}
936
936
937
+ Y_UNIT_TEST (IndexPartitioningIsPersisted) {
938
+ TTestBasicRuntime runtime;
939
+ TTestEnv env (runtime);
940
+ ui64 txId = 100 ;
941
+
942
+ TestCreateTable (runtime, ++txId, " /MyRoot" , R"(
943
+ Name: "Table"
944
+ Columns { Name: "key" Type: "Uint64" }
945
+ Columns { Name: "value" Type: "Utf8" }
946
+ KeyColumnNames: [ "key" ]
947
+ )" );
948
+ env.TestWaitNotification (runtime, txId);
949
+
950
+ Ydb::Table::GlobalIndexSettings settings;
951
+ UNIT_ASSERT (google::protobuf::TextFormat::ParseFromString (R"(
952
+ partition_at_keys {
953
+ split_points {
954
+ type { tuple_type { elements { optional_type { item { type_id: UTF8 } } } } }
955
+ value { items { text_value: "alice" } }
956
+ }
957
+ split_points {
958
+ type { tuple_type { elements { optional_type { item { type_id: UTF8 } } } } }
959
+ value { items { text_value: "bob" } }
960
+ }
961
+ }
962
+ partitioning_settings {
963
+ min_partitions_count: 3
964
+ max_partitions_count: 3
965
+ }
966
+ )" , &settings));
967
+
968
+ TBlockEvents<TEvSchemeShard::TEvModifySchemeTransaction> indexCreationBlocker (runtime, [](const auto & ev) {
969
+ const auto & modifyScheme = ev->Get ()->Record .GetTransaction (0 );
970
+ return modifyScheme.GetOperationType () == NKikimrSchemeOp::ESchemeOpCreateIndexBuild;
971
+ });
972
+
973
+ const ui64 buildIndexTx = ++txId;
974
+ TestBuildIndex (runtime, buildIndexTx, TTestTxConfig::SchemeShard, " /MyRoot" , " /MyRoot/Table" , TBuildIndexConfig{
975
+ " Index" , NKikimrSchemeOp::EIndexTypeGlobal, { " value" }, {},
976
+ { NYdb::NTable::TGlobalIndexSettings::FromProto (settings) }
977
+ });
978
+
979
+ RebootTablet (runtime, TTestTxConfig::SchemeShard, runtime.AllocateEdgeActor ());
980
+
981
+ indexCreationBlocker.Stop ().Unblock ();
982
+ env.TestWaitNotification (runtime, buildIndexTx);
983
+
984
+ auto buildIndexOperation = TestGetBuildIndex (runtime, TTestTxConfig::SchemeShard, " /MyRoot" , buildIndexTx);
985
+ UNIT_ASSERT_VALUES_EQUAL_C (
986
+ buildIndexOperation.GetIndexBuild ().GetState (), Ydb::Table::IndexBuildState::STATE_DONE,
987
+ buildIndexOperation.DebugString ()
988
+ );
989
+
990
+ TestDescribeResult (DescribePath (runtime, " /MyRoot/Table" ), {
991
+ NLs::IsTable,
992
+ NLs::IndexesCount (1 )
993
+ });
994
+
995
+ TestDescribeResult (DescribePrivatePath (runtime, " /MyRoot/Table/Index" ), {
996
+ NLs::PathExist,
997
+ NLs::IndexState (NKikimrSchemeOp::EIndexState::EIndexStateReady)
998
+ });
999
+
1000
+ TestDescribeResult (DescribePrivatePath (runtime, " /MyRoot/Table/Index/indexImplTable" , true , true ), {
1001
+ NLs::IsTable,
1002
+ NLs::PartitionCount (3 ),
1003
+ NLs::MinPartitionsCountEqual (3 ),
1004
+ NLs::MaxPartitionsCountEqual (3 ),
1005
+ NLs::PartitionKeys ({" alice" , " bob" , " " })
1006
+ });
1007
+ }
1008
+
937
1009
Y_UNIT_TEST (DropIndex) {
938
1010
TTestBasicRuntime runtime;
939
1011
TTestEnv env (runtime);
0 commit comments