@@ -460,6 +460,50 @@ public void testUpgradeFourToFiveWithMetadataTableFailure() throws Exception {
460
460
"Main table version should remain unchanged when metadata table upgrade fails" );
461
461
}
462
462
463
+ @ Test
464
+ public void testAutoUpgradeDisabledDuringUpgrade () throws Exception {
465
+ // Follow same setup of testUpgradeFourToFiveInternal
466
+ String tableName = metaClient .getTableConfig ().getTableName ();
467
+ cleanUp ();
468
+ initSparkContexts ();
469
+ initPath ();
470
+ initTestDataGenerator ();
471
+
472
+ Map <String , String > params = new HashMap <>();
473
+ addNewTableParamsToProps (params , tableName );
474
+ Properties properties = new Properties ();
475
+ params .forEach ((k , v ) -> properties .setProperty (k , v ));
476
+
477
+ initMetaClient (getTableType (), properties );
478
+ // Create config with auto-upgrade disabled
479
+ HoodieWriteConfig cfg = getConfigBuilder ()
480
+ .withRollbackUsingMarkers (false )
481
+ .withWriteTableVersion (6 )
482
+ .withAutoUpgradeVersion (false ) // Disable auto-upgrade
483
+ .withProps (params )
484
+ .build ();
485
+
486
+ SparkRDDWriteClient client = getHoodieWriteClient (cfg );
487
+ // Write inserts to establish table
488
+ doInsert (client );
489
+
490
+ // Downgrade to version 4 first
491
+ downgradeTableConfigsFromFiveToFour (cfg );
492
+
493
+ metaClient = HoodieTableMetaClient .reload (metaClient );
494
+ HoodieTableVersion originalVersion = metaClient .getTableConfig ().getTableVersion ();
495
+ assertEquals (HoodieTableVersion .FOUR , originalVersion , "Table should be at version 4 before test" );
496
+
497
+ // Attempt upgrade from version 4 to 5 with auto-upgrade disabled
498
+ new UpgradeDowngrade (metaClient , cfg , context , SparkUpgradeDowngradeHelper .getInstance ())
499
+ .run (HoodieTableVersion .FIVE , null );
500
+
501
+ // Verify that upgrade was skipped and table version remains unchanged
502
+ metaClient = HoodieTableMetaClient .reload (metaClient );
503
+ assertEquals (HoodieTableVersion .FOUR , metaClient .getTableConfig ().getTableVersion (),
504
+ "Table version should remain at 4 when auto-upgrade is disabled" );
505
+ }
506
+
463
507
private void testUpgradeFourToFiveInternal (boolean assertDefaultPartition , boolean skipDefaultPartitionValidation , boolean isHiveStyle ) throws Exception {
464
508
String tableName = metaClient .getTableConfig ().getTableName ();
465
509
// clean up and re instantiate meta client w/ right table props
0 commit comments