@@ -69,7 +69,7 @@ namespace {
69
69
}; \
70
70
static TTestRegistration##N testRegistration##N; \
71
71
template <ENUM_TYPE Value> \
72
- void TTestCase##N<Value>::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED)
72
+ void TTestCase##N<Value>::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED)
73
73
74
74
#define DEBUG_HINT (TStringBuilder() << " at line " << __LINE__)
75
75
@@ -316,48 +316,24 @@ void TestTableSplitBoundariesArePreserved(
316
316
}
317
317
318
318
void TestIndexTableSplitBoundariesArePreserved (
319
- const char * table, const char * index, ui64 indexPartitions, TSession& session,
319
+ const char * table, const char * index, ui64 indexPartitions, TSession& session, TTableBuilder& tableBuilder,
320
320
TBackupFunction&& backup, TRestoreFunction&& restore
321
321
) {
322
- const TString indexTablePath = JoinFsPaths (table, index, " indexImplTable" );
323
-
324
322
{
325
- TExplicitPartitions indexPartitionBoundaries;
326
- for (ui32 boundary : {1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 }) {
327
- indexPartitionBoundaries.AppendSplitPoints (
328
- // split boundary is technically always a tuple
329
- TValueBuilder ().BeginTuple ().AddElement ().OptionalUint32 (boundary).EndTuple ().Build ()
330
- );
331
- }
332
- // By default indexImplTable has auto partitioning by size enabled,
333
- // so you must set min partition count for partitions to not merge immediately after indexImplTable is built.
334
- TPartitioningSettingsBuilder partitioningSettingsBuilder;
335
- partitioningSettingsBuilder
336
- .SetMinPartitionsCount (indexPartitions)
337
- .SetMaxPartitionsCount (indexPartitions);
338
-
339
- const auto indexSettings = TGlobalIndexSettings{
340
- .PartitioningSettings = partitioningSettingsBuilder.Build (),
341
- .Partitions = std::move (indexPartitionBoundaries)
342
- };
343
-
344
- auto tableBuilder = TTableBuilder ()
345
- .AddNullableColumn (" Key" , EPrimitiveType::Uint32)
346
- .AddNullableColumn (" Value" , EPrimitiveType::Uint32)
347
- .SetPrimaryKeyColumn (" Key" )
348
- .AddSecondaryIndex (TIndexDescription (" byValue" , EIndexType::GlobalSync, { " Value" }, {}, { indexSettings }));
349
-
350
323
const auto result = session.CreateTable (table, tableBuilder.Build ()).ExtractValueSync ();
351
324
UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
352
325
}
326
+
327
+ const TString indexTablePath = JoinFsPaths (table, index, " indexImplTable" );
353
328
const auto describeSettings = TDescribeTableSettings ()
354
329
.WithTableStatistics (true )
355
330
.WithKeyShardBoundary (true );
356
- const auto originalIndexTableDescription = GetTableDescription (
331
+
332
+ const auto originalDescription = GetTableDescription (
357
333
session, indexTablePath, describeSettings
358
334
);
359
- UNIT_ASSERT_VALUES_EQUAL (originalIndexTableDescription .GetPartitionsCount (), indexPartitions);
360
- const auto & originalKeyRanges = originalIndexTableDescription .GetKeyRanges ();
335
+ UNIT_ASSERT_VALUES_EQUAL (originalDescription .GetPartitionsCount (), indexPartitions);
336
+ const auto & originalKeyRanges = originalDescription .GetKeyRanges ();
361
337
UNIT_ASSERT_VALUES_EQUAL (originalKeyRanges.size (), indexPartitions);
362
338
363
339
backup (table);
@@ -368,11 +344,11 @@ void TestIndexTableSplitBoundariesArePreserved(
368
344
));
369
345
370
346
restore (table);
371
- const auto restoredIndexTableDescription = GetTableDescription (
347
+ const auto restoredDescription = GetTableDescription (
372
348
session, indexTablePath, describeSettings
373
349
);
374
- UNIT_ASSERT_VALUES_EQUAL (restoredIndexTableDescription .GetPartitionsCount (), indexPartitions);
375
- const auto & restoredKeyRanges = restoredIndexTableDescription .GetKeyRanges ();
350
+ UNIT_ASSERT_VALUES_EQUAL (restoredDescription .GetPartitionsCount (), indexPartitions);
351
+ const auto & restoredKeyRanges = restoredDescription .GetKeyRanges ();
376
352
UNIT_ASSERT_VALUES_EQUAL (restoredKeyRanges.size (), indexPartitions);
377
353
UNIT_ASSERT_EQUAL (restoredKeyRanges, originalKeyRanges);
378
354
}
@@ -464,7 +440,7 @@ void TestRestoreTableWithIndex(
464
440
DROP TABLE `%s`;
465
441
)" , table
466
442
));
467
-
443
+
468
444
restore (table);
469
445
470
446
CheckTableDescription (session, table, CreateHasIndexChecker (index, ConvertIndexTypeToAPI (indexType)));
@@ -608,7 +584,7 @@ Y_UNIT_TEST_SUITE(BackupRestore) {
608
584
const auto & pathToBackup = tempDir.Path ();
609
585
constexpr const char * table = " /Root/table" ;
610
586
constexpr const char * index = " byValue" ;
611
-
587
+
612
588
TestRestoreTableWithIndex (
613
589
table,
614
590
index,
@@ -655,7 +631,7 @@ Y_UNIT_TEST_SUITE(BackupRestore) {
655
631
656
632
Y_UNIT_TEST_ALL_PROTO_ENUM_VALUES (TestAllSchemeObjectTypes, NKikimrSchemeOp::EPathType) {
657
633
using namespace NKikimrSchemeOp ;
658
-
634
+
659
635
switch (Value) {
660
636
case EPathTypeTable:
661
637
TestTableBackupRestore ();
@@ -707,7 +683,7 @@ Y_UNIT_TEST_SUITE(BackupRestore) {
707
683
708
684
Y_UNIT_TEST_ALL_PROTO_ENUM_VALUES (TestAllIndexTypes, NKikimrSchemeOp::EIndexType) {
709
685
using namespace NKikimrSchemeOp ;
710
-
686
+
711
687
switch (Value) {
712
688
case EIndexTypeGlobal:
713
689
case EIndexTypeGlobalAsync:
@@ -907,11 +883,88 @@ Y_UNIT_TEST_SUITE(BackupRestoreS3) {
907
883
constexpr const char * index = " byValue" ;
908
884
constexpr ui64 indexPartitions = 10 ;
909
885
886
+ TExplicitPartitions indexPartitionBoundaries;
887
+ for (ui32 i = 1 ; i < indexPartitions; ++i) {
888
+ indexPartitionBoundaries.AppendSplitPoints (
889
+ // split boundary is technically always a tuple
890
+ TValueBuilder ().BeginTuple ().AddElement ().OptionalUint32 (i * 10 ).EndTuple ().Build ()
891
+ );
892
+ }
893
+ // By default indexImplTables have auto partitioning by size enabled.
894
+ // If you don't want the partitions to merge immediately after the indexImplTable is built,
895
+ // you must set the min partition count for the table.
896
+ TPartitioningSettingsBuilder partitioningSettingsBuilder;
897
+ partitioningSettingsBuilder
898
+ .SetMinPartitionsCount (indexPartitions)
899
+ .SetMaxPartitionsCount (indexPartitions);
900
+
901
+ const auto indexSettings = TGlobalIndexSettings{
902
+ .PartitioningSettings = partitioningSettingsBuilder.Build (),
903
+ .Partitions = std::move (indexPartitionBoundaries)
904
+ };
905
+
906
+ auto tableBuilder = TTableBuilder ()
907
+ .AddNullableColumn (" Key" , EPrimitiveType::Uint32)
908
+ .AddNullableColumn (" Value" , EPrimitiveType::Uint32)
909
+ .SetPrimaryKeyColumn (" Key" )
910
+ .AddSecondaryIndex (TIndexDescription (index, EIndexType::GlobalSync, { " Value" }, {}, { indexSettings }));
911
+
912
+ TestIndexTableSplitBoundariesArePreserved (
913
+ table,
914
+ index,
915
+ indexPartitions,
916
+ testEnv.GetSession (),
917
+ tableBuilder,
918
+ CreateBackupLambda (testEnv.GetDriver (), testEnv.GetS3Port ()),
919
+ CreateRestoreLambda (testEnv.GetDriver (), testEnv.GetS3Port ())
920
+ );
921
+ }
922
+
923
+ Y_UNIT_TEST (RestoreIndexTableDecimalSplitBoundaries) {
924
+ TS3TestEnv testEnv;
925
+ constexpr const char * table = " /Root/table" ;
926
+ constexpr const char * index = " byValue" ;
927
+ constexpr ui64 indexPartitions = 10 ;
928
+
929
+ constexpr ui8 decimalPrecision = 22 ;
930
+ constexpr ui8 decimalScale = 9 ;
931
+
932
+ TExplicitPartitions indexPartitionBoundaries;
933
+ for (ui32 i = 1 ; i < indexPartitions; ++i) {
934
+ TDecimalValue boundary (ToString (i * 10 ), decimalPrecision, decimalScale);
935
+ indexPartitionBoundaries.AppendSplitPoints (
936
+ // split boundary is technically always a tuple
937
+ TValueBuilder ()
938
+ .BeginTuple ().AddElement ()
939
+ .BeginOptional ().Decimal (boundary).EndOptional ()
940
+ .EndTuple ().Build ()
941
+ );
942
+ }
943
+ // By default indexImplTables have auto partitioning by size enabled.
944
+ // If you don't want the partitions to merge immediately after the indexImplTable is built,
945
+ // you must set the min partition count for the table.
946
+ TPartitioningSettingsBuilder partitioningSettingsBuilder;
947
+ partitioningSettingsBuilder
948
+ .SetMinPartitionsCount (indexPartitions)
949
+ .SetMaxPartitionsCount (indexPartitions);
950
+
951
+ const auto indexSettings = TGlobalIndexSettings{
952
+ .PartitioningSettings = partitioningSettingsBuilder.Build (),
953
+ .Partitions = std::move (indexPartitionBoundaries)
954
+ };
955
+
956
+ auto tableBuilder = TTableBuilder ()
957
+ .AddNullableColumn (" Key" , EPrimitiveType::Uint32)
958
+ .AddNullableColumn (" Value" , TDecimalType (decimalPrecision, decimalScale))
959
+ .SetPrimaryKeyColumn (" Key" )
960
+ .AddSecondaryIndex (TIndexDescription (index, EIndexType::GlobalSync, { " Value" }, {}, { indexSettings }));
961
+
910
962
TestIndexTableSplitBoundariesArePreserved (
911
963
table,
912
964
index,
913
965
indexPartitions,
914
966
testEnv.GetSession (),
967
+ tableBuilder,
915
968
CreateBackupLambda (testEnv.GetDriver (), testEnv.GetS3Port ()),
916
969
CreateRestoreLambda (testEnv.GetDriver (), testEnv.GetS3Port ())
917
970
);
@@ -958,7 +1011,7 @@ Y_UNIT_TEST_SUITE(BackupRestoreS3) {
958
1011
959
1012
Y_UNIT_TEST_ALL_PROTO_ENUM_VALUES (TestAllSchemeObjectTypes, NKikimrSchemeOp::EPathType) {
960
1013
using namespace NKikimrSchemeOp ;
961
-
1014
+
962
1015
switch (Value) {
963
1016
case EPathTypeTable:
964
1017
TestTableBackupRestore ();
@@ -1009,7 +1062,7 @@ Y_UNIT_TEST_SUITE(BackupRestoreS3) {
1009
1062
1010
1063
Y_UNIT_TEST_ALL_PROTO_ENUM_VALUES (TestAllIndexTypes, NKikimrSchemeOp::EIndexType) {
1011
1064
using namespace NKikimrSchemeOp ;
1012
-
1065
+
1013
1066
switch (Value) {
1014
1067
case EIndexTypeGlobal:
1015
1068
case EIndexTypeGlobalAsync:
0 commit comments