@@ -933,6 +933,49 @@ public void testStreamWriteFrequentCompactWithOverlappingKeys() throws Exception
933933 }
934934 }
935935
936+ @ Test
937+ public void testNoUpgradeForPkClusteringOverride () throws Exception {
938+ Identifier identifier = Identifier .create ("default" , "no_upgrade_table" );
939+ Schema schema =
940+ Schema .newBuilder ()
941+ .column ("a" , DataTypes .INT ())
942+ .column ("b" , DataTypes .INT ())
943+ .primaryKey ("a" )
944+ .option (DELETION_VECTORS_ENABLED .key (), "true" )
945+ .option (BUCKET .key (), "1" )
946+ .option (CLUSTERING_COLUMNS .key (), "b" )
947+ .option (PK_CLUSTERING_OVERRIDE .key (), "true" )
948+ .option ("write-only" , "true" )
949+ .build ();
950+ catalog .createTable (identifier , schema , false );
951+ Table writeOnlyTable = catalog .getTable (identifier );
952+
953+ // normal append commit to create initial data
954+ BatchWriteBuilder appendBuilder = writeOnlyTable .newBatchWriteBuilder ();
955+ try (BatchTableWrite write = appendBuilder .newWrite ().withIOManager (ioManager );
956+ BatchTableCommit commit = appendBuilder .newCommit ()) {
957+ write .write (GenericRow .of (1 , 10 ));
958+ write .write (GenericRow .of (2 , 20 ));
959+ commit .commit (write .prepareCommit ());
960+ }
961+
962+ // overwrite commit — files should NOT be upgraded because pkClusteringOverride is true
963+ BatchWriteBuilder overwriteBuilder = writeOnlyTable .newBatchWriteBuilder ().withOverwrite ();
964+ try (BatchTableWrite write = overwriteBuilder .newWrite ().withIOManager (ioManager );
965+ BatchTableCommit commit = overwriteBuilder .newCommit ()) {
966+ write .write (GenericRow .of (3 , 30 ));
967+ write .write (GenericRow .of (4 , 40 ));
968+ commit .commit (write .prepareCommit ());
969+ }
970+
971+ List <Split > splits = writeOnlyTable .newReadBuilder ().newScan ().plan ().splits ();
972+ for (Split split : splits ) {
973+ for (DataFileMeta file : ((DataSplit ) split ).dataFiles ()) {
974+ assertThat (file .level ()).isEqualTo (0 );
975+ }
976+ }
977+ }
978+
936979 private Table createFirstRowTableWithLowSpillThreshold () throws Exception {
937980 Identifier identifier = Identifier .create ("default" , "first_row_spill_table" );
938981 Schema schema =
0 commit comments