@@ -66,7 +66,7 @@ void testOptimizeManifestWithNullPartitions()
6666 assertUpdate ("ALTER TABLE " + table .getName () + " EXECUTE optimize_manifests" );
6767
6868 assertThat (manifestFiles (table .getName ()))
69- .hasSize (2 )
69+ .hasSize (1 )
7070 .doesNotContainAnyElementsOf (manifestFiles );
7171
7272 assertThat (query ("SELECT * FROM " + table .getName ()))
@@ -138,7 +138,7 @@ void testPartitionTable()
138138
139139 assertUpdate ("ALTER TABLE " + table .getName () + " EXECUTE optimize_manifests" );
140140 assertThat (manifestFiles (table .getName ()))
141- .hasSize (2 )
141+ .hasSize (1 )
142142 .doesNotContainAnyElementsOf (manifestFiles );
143143
144144 assertThat (query ("SELECT * FROM " + table .getName ()))
@@ -147,24 +147,40 @@ void testPartitionTable()
147147 }
148148
149149 @ Test
150- void testFirstPartitionField ()
150+ void testMultiplePartitioningColumns ()
151151 {
152152 try (TestTable table = newTrinoTable ("test_partition" , "(id int, part int, nested int) WITH (partitioning = ARRAY['part', 'nested'])" )) {
153- assertUpdate ("INSERT INTO " + table .getName () + " VALUES (1, 10, 100)" , 1 );
154- assertUpdate ("INSERT INTO " + table .getName () + " VALUES (2, 10, 200)" , 1 );
155- assertUpdate ("INSERT INTO " + table .getName () + " VALUES (3, 20, 300)" , 1 );
156- assertUpdate ("INSERT INTO " + table .getName () + " VALUES (4, 20, 400)" , 1 );
153+ for (int i = 0 ; i < 30 ; i ++) {
154+ assertUpdate ("INSERT INTO " + table .getName () + " VALUES (%d, %d, %d)" .formatted (i , i % 10 , i % 3 ), 1 );
155+ }
157156
158157 Set <String > manifestFiles = manifestFiles (table .getName ());
159- assertThat (manifestFiles ).hasSize (4 );
158+ assertThat (manifestFiles ).hasSize (30 );
160159
161160 assertUpdate ("ALTER TABLE " + table .getName () + " EXECUTE optimize_manifests" );
162- assertThat (manifestFiles (table .getName ()))
161+ Set <String > currentManifestFiles = manifestFiles (table .getName ());
162+ assertThat (currentManifestFiles )
163+ .hasSize (1 )
164+ .doesNotContainAnyElementsOf (manifestFiles );
165+
166+ assertThat (query ("SELECT COUNT(*) FROM " + table .getName ()))
167+ .matches ("VALUES BIGINT '30'" );
168+
169+ // Set small target size to force split
170+ BaseTable icebergTable = loadTable (table .getName ());
171+ icebergTable .updateProperties ()
172+ .set ("commit.manifest.target-size-bytes" , "8000" )
173+ .commit ();
174+ manifestFiles = currentManifestFiles ;
175+ assertUpdate ("ALTER TABLE " + table .getName () + " EXECUTE optimize_manifests" );
176+
177+ currentManifestFiles = manifestFiles (table .getName ());
178+ assertThat (currentManifestFiles )
163179 .hasSize (2 )
164180 .doesNotContainAnyElementsOf (manifestFiles );
165181
166- assertThat (query ("SELECT * FROM " + table .getName ()))
167- .matches ("VALUES (1, 10, 100), (2, 10, 200), (3, 20, 300), (4, 20, 400) " );
182+ assertThat (query ("SELECT COUNT(*) FROM " + table .getName ()))
183+ .matches ("VALUES BIGINT '30' " );
168184 }
169185 }
170186
0 commit comments