@@ -331,15 +331,20 @@ public void testUpgradeDowngradeBetweenThreeAndCurrentVersion() throws IOExcepti
331331
332332 @ Test
333333 public void testUpgradeFourtoFive () throws Exception {
334- testUpgradeFourToFiveInternal (false );
334+ testUpgradeFourToFiveInternal (false , false );
335335 }
336336
337337 @ Test
338338 public void testUpgradeFourtoFiveWithDefaultPartition () throws Exception {
339- testUpgradeFourToFiveInternal (true );
339+ testUpgradeFourToFiveInternal (true , false );
340340 }
341341
342- private void testUpgradeFourToFiveInternal (boolean assertDefaultPartition ) throws Exception {
342+ @ Test
343+ public void testUpgradeFourtoFiveWithDefaultPartitionWithSkipValidation () throws Exception {
344+ testUpgradeFourToFiveInternal (true , true );
345+ }
346+
347+ private void testUpgradeFourToFiveInternal (boolean assertDefaultPartition , boolean skipDefaultPartitionValidation ) throws Exception {
343348 String tableName = metaClient .getTableConfig ().getTableName ();
344349 // clean up and re instantiate meta client w/ right table props
345350 cleanUp ();
@@ -354,7 +359,8 @@ private void testUpgradeFourToFiveInternal(boolean assertDefaultPartition) throw
354359
355360 initMetaClient (getTableType (), properties );
356361 // init config, table and client.
357- HoodieWriteConfig cfg = getConfigBuilder ().withAutoCommit (false ).withRollbackUsingMarkers (false ).withProps (params ).build ();
362+ HoodieWriteConfig cfg = getConfigBuilder ().withAutoCommit (false ).withRollbackUsingMarkers (false )
363+ .doSkipDefaultPartitionValidation (skipDefaultPartitionValidation ).withProps (params ).build ();
358364 SparkRDDWriteClient client = getHoodieWriteClient (cfg );
359365 // Write inserts
360366 doInsert (client );
@@ -367,7 +373,11 @@ private void testUpgradeFourToFiveInternal(boolean assertDefaultPartition) throw
367373 downgradeTableConfigsFromFiveToFour (cfg );
368374
369375 // perform upgrade
370- if (!assertDefaultPartition ) {
376+ if (assertDefaultPartition && !skipDefaultPartitionValidation ) {
377+ // if "default" partition is present, upgrade should fail
378+ assertThrows (HoodieException .class , () -> new UpgradeDowngrade (metaClient , cfg , context , SparkUpgradeDowngradeHelper .getInstance ())
379+ .run (HoodieTableVersion .FIVE , null ), "Upgrade from 4 to 5 is expected to fail if \" default\" partition is present." );
380+ } else {
371381 new UpgradeDowngrade (metaClient , cfg , context , SparkUpgradeDowngradeHelper .getInstance ())
372382 .run (HoodieTableVersion .FIVE , null );
373383
@@ -378,10 +388,6 @@ private void testUpgradeFourToFiveInternal(boolean assertDefaultPartition) throw
378388
379389 // verify table props
380390 assertTableProps (cfg );
381- } else {
382- // if "default" partition is present, upgrade should fail
383- assertThrows (HoodieException .class , () -> new UpgradeDowngrade (metaClient , cfg , context , SparkUpgradeDowngradeHelper .getInstance ())
384- .run (HoodieTableVersion .FIVE , null ), "Upgrade from 4 to 5 is expected to fail if \" default\" partition is present." );
385391 }
386392 }
387393
0 commit comments