@@ -3107,6 +3107,22 @@ Y_UNIT_TEST_SUITE(IncrementalBackup) {
31073107 )" );
31083108 UNIT_ASSERT_C (indexQuery.find (" uint32_value: 2" ) != TString::npos, " Should find key=2" );
31093109 UNIT_ASSERT_C (indexQuery.find (" uint32_value: 250" ) != TString::npos, " Should find indexed_col=250" );
3110+
3111+ // Verify index implementation table was restored correctly
3112+ auto indexImplTable = KqpSimpleExec (runtime, R"(
3113+ SELECT indexed_col, key FROM `/Root/TableWithIndex/value_index/indexImplTable` ORDER BY indexed_col
3114+ )" );
3115+ // Should have 4 rows after incremental: (100,1), (250,2), (300,3), (400,4)
3116+ UNIT_ASSERT_C (indexImplTable.find (" uint32_value: 100" ) != TString::npos, " Index table should have indexed_col=100" );
3117+ UNIT_ASSERT_C (indexImplTable.find (" uint32_value: 250" ) != TString::npos, " Index table should have indexed_col=250" );
3118+ UNIT_ASSERT_C (indexImplTable.find (" uint32_value: 300" ) != TString::npos, " Index table should have indexed_col=300" );
3119+ UNIT_ASSERT_C (indexImplTable.find (" uint32_value: 400" ) != TString::npos, " Index table should have indexed_col=400" );
3120+
3121+ // Count rows in index impl table
3122+ auto indexRowCount = KqpSimpleExec (runtime, R"(
3123+ SELECT COUNT(*) FROM `/Root/TableWithIndex/value_index/indexImplTable`
3124+ )" );
3125+ UNIT_ASSERT_C (indexRowCount.find (" uint64_value: 4" ) != TString::npos, " Index table should have 4 rows" );
31103126 }
31113127
31123128 Y_UNIT_TEST (MultipleIndexesIncrementalRestore) {
@@ -3204,6 +3220,29 @@ Y_UNIT_TEST_SUITE(IncrementalBackup) {
32043220 SELECT key FROM `/Root/MultiIndexTable` VIEW index3 WHERE value3 = 34
32053221 )" );
32063222 UNIT_ASSERT_C (index3Query.find (" uint32_value: 4" ) != TString::npos, " Index3 should work" );
3223+
3224+ // Verify all index implementation tables were restored
3225+ auto index1ImplCount = KqpSimpleExec (runtime, R"(
3226+ SELECT COUNT(*) FROM `/Root/MultiIndexTable/index1/indexImplTable`
3227+ )" );
3228+ UNIT_ASSERT_C (index1ImplCount.find (" uint64_value: 4" ) != TString::npos, " Index1 impl table should have 4 rows" );
3229+
3230+ auto index2ImplCount = KqpSimpleExec (runtime, R"(
3231+ SELECT COUNT(*) FROM `/Root/MultiIndexTable/index2/indexImplTable`
3232+ )" );
3233+ UNIT_ASSERT_C (index2ImplCount.find (" uint64_value: 4" ) != TString::npos, " Index2 impl table should have 4 rows" );
3234+
3235+ auto index3ImplCount = KqpSimpleExec (runtime, R"(
3236+ SELECT COUNT(*) FROM `/Root/MultiIndexTable/index3/indexImplTable`
3237+ )" );
3238+ UNIT_ASSERT_C (index3ImplCount.find (" uint64_value: 4" ) != TString::npos, " Index3 impl table should have 4 rows" );
3239+
3240+ // Verify index3 impl table data (spot check)
3241+ auto index3ImplData = KqpSimpleExec (runtime, R"(
3242+ SELECT value3, key FROM `/Root/MultiIndexTable/index3/indexImplTable` WHERE value3 = 34
3243+ )" );
3244+ UNIT_ASSERT_C (index3ImplData.find (" uint32_value: 34" ) != TString::npos, " Index3 impl should have value3=34" );
3245+ UNIT_ASSERT_C (index3ImplData.find (" uint32_value: 4" ) != TString::npos, " Index3 impl should have key=4" );
32073246 }
32083247
32093248 Y_UNIT_TEST (IndexDataVerificationIncrementalRestore) {
@@ -3300,6 +3339,24 @@ Y_UNIT_TEST_SUITE(IncrementalBackup) {
33003339 UNIT_ASSERT_C (afterRestore.find (" text_value: \" Alice\" " ) == TString::npos, " Alice should be deleted" );
33013340 UNIT_ASSERT_C (afterRestore.find (" text_value: \" Frank\" " ) != TString::npos, " Frank should be present" );
33023341 UNIT_ASSERT_C (afterRestore.find (" uint32_value: 45" ) != TString::npos, " Age 45 should be present" );
3342+
3343+ // Verify index implementation table has correct data
3344+ auto indexImplData = KqpSimpleExec (runtime, R"(
3345+ SELECT age, key, name FROM `/Root/DataVerifyTable/age_index/indexImplTable` ORDER BY age
3346+ )" );
3347+ // Should have: (28, 3, Eve), (31, 2, Bob), (41, 12, David), (45, 13, Frank)
3348+ // Deleted: (25, 1, Alice), (35, 11, Charlie)
3349+ UNIT_ASSERT_C (indexImplData.find (" uint32_value: 28" ) != TString::npos, " Index should have age=28" );
3350+ UNIT_ASSERT_C (indexImplData.find (" text_value: \" Eve\" " ) != TString::npos, " Index should have Eve" );
3351+ UNIT_ASSERT_C (indexImplData.find (" uint32_value: 31" ) != TString::npos, " Index should have age=31" );
3352+ UNIT_ASSERT_C (indexImplData.find (" text_value: \" Bob\" " ) != TString::npos, " Index should have Bob" );
3353+ UNIT_ASSERT_C (indexImplData.find (" text_value: \" Alice\" " ) == TString::npos, " Index should NOT have Alice" );
3354+ UNIT_ASSERT_C (indexImplData.find (" text_value: \" Charlie\" " ) == TString::npos, " Index should NOT have Charlie" );
3355+
3356+ auto indexImplCount = KqpSimpleExec (runtime, R"(
3357+ SELECT COUNT(*) FROM `/Root/DataVerifyTable/age_index/indexImplTable`
3358+ )" );
3359+ UNIT_ASSERT_C (indexImplCount.find (" uint64_value: 4" ) != TString::npos, " Index impl table should have 4 rows" );
33033360 }
33043361
33053362 Y_UNIT_TEST (MultipleIncrementalBackupsWithIndexes) {
@@ -3406,6 +3463,23 @@ Y_UNIT_TEST_SUITE(IncrementalBackup) {
34063463 UNIT_ASSERT_C (actualTable.find (" uint32_value: 25" ) != TString::npos, " Key 2 should have value 25" );
34073464 UNIT_ASSERT_C (actualTable.find (" uint32_value: 30" ) != TString::npos, " Key 3 should exist" );
34083465 UNIT_ASSERT_C (actualTable.find (" uint32_value: 40" ) != TString::npos, " Key 4 should exist" );
3466+
3467+ // Verify index implementation table reflects all 3 incremental changes
3468+ auto indexImplData = KqpSimpleExec (runtime, R"(
3469+ SELECT indexed, key FROM `/Root/SequenceTable/idx/indexImplTable` ORDER BY indexed
3470+ )" );
3471+ // Final state should be: (250, 2), (300, 3), (400, 4)
3472+ // Deleted: (100, 1), (200, 2->old value)
3473+ UNIT_ASSERT_C (indexImplData.find (" uint32_value: 100" ) == TString::npos, " Index should NOT have indexed=100 (deleted)" );
3474+ UNIT_ASSERT_C (indexImplData.find (" uint32_value: 200" ) == TString::npos, " Index should NOT have indexed=200 (updated)" );
3475+ UNIT_ASSERT_C (indexImplData.find (" uint32_value: 250" ) != TString::npos, " Index should have indexed=250 (updated value)" );
3476+ UNIT_ASSERT_C (indexImplData.find (" uint32_value: 300" ) != TString::npos, " Index should have indexed=300 (added)" );
3477+ UNIT_ASSERT_C (indexImplData.find (" uint32_value: 400" ) != TString::npos, " Index should have indexed=400 (added)" );
3478+
3479+ auto indexImplCount = KqpSimpleExec (runtime, R"(
3480+ SELECT COUNT(*) FROM `/Root/SequenceTable/idx/indexImplTable`
3481+ )" );
3482+ UNIT_ASSERT_C (indexImplCount.find (" uint64_value: 3" ) != TString::npos, " Index impl table should have 3 rows" );
34093483 }
34103484
34113485 Y_UNIT_TEST (MultipleTablesWithIndexesIncrementalRestore) {
@@ -3515,6 +3589,30 @@ Y_UNIT_TEST_SUITE(IncrementalBackup) {
35153589 SELECT key FROM `/Root/Table2` VIEW idx2 WHERE val2 = 3000
35163590 )" );
35173591 UNIT_ASSERT_C (idx2Query.find (" uint32_value: 3" ) != TString::npos, " Index idx2 should work" );
3592+
3593+ // Verify both index implementation tables were restored
3594+ auto idx1ImplCount = KqpSimpleExec (runtime, R"(
3595+ SELECT COUNT(*) FROM `/Root/Table1/idx1/indexImplTable`
3596+ )" );
3597+ UNIT_ASSERT_C (idx1ImplCount.find (" uint64_value: 3" ) != TString::npos, " Table1 index impl should have 3 rows" );
3598+
3599+ auto idx2ImplCount = KqpSimpleExec (runtime, R"(
3600+ SELECT COUNT(*) FROM `/Root/Table2/idx2/indexImplTable`
3601+ )" );
3602+ UNIT_ASSERT_C (idx2ImplCount.find (" uint64_value: 3" ) != TString::npos, " Table2 index impl should have 3 rows" );
3603+
3604+ // Verify index impl tables have correct data
3605+ auto idx1ImplData = KqpSimpleExec (runtime, R"(
3606+ SELECT val1, key FROM `/Root/Table1/idx1/indexImplTable` WHERE val1 = 300
3607+ )" );
3608+ UNIT_ASSERT_C (idx1ImplData.find (" uint32_value: 300" ) != TString::npos, " Table1 index should have val1=300" );
3609+ UNIT_ASSERT_C (idx1ImplData.find (" uint32_value: 3" ) != TString::npos, " Table1 index should have key=3" );
3610+
3611+ auto idx2ImplData = KqpSimpleExec (runtime, R"(
3612+ SELECT val2, key FROM `/Root/Table2/idx2/indexImplTable` WHERE val2 = 3000
3613+ )" );
3614+ UNIT_ASSERT_C (idx2ImplData.find (" uint32_value: 3000" ) != TString::npos, " Table2 index should have val2=3000" );
3615+ UNIT_ASSERT_C (idx2ImplData.find (" uint32_value: 3" ) != TString::npos, " Table2 index should have key=3" );
35183616 }
35193617
35203618
0 commit comments