4242import org .apache .paimon .rest .auth .AuthProvider ;
4343import org .apache .paimon .rest .auth .RESTAuthParameter ;
4444import org .apache .paimon .rest .requests .AlterDatabaseRequest ;
45- import org .apache .paimon .rest .requests .AlterPartitionsRequest ;
4645import org .apache .paimon .rest .requests .AlterTableRequest ;
4746import org .apache .paimon .rest .requests .CommitTableRequest ;
4847import org .apache .paimon .rest .requests .CreateBranchRequest ;
4948import org .apache .paimon .rest .requests .CreateDatabaseRequest ;
50- import org .apache .paimon .rest .requests .CreatePartitionsRequest ;
5149import org .apache .paimon .rest .requests .CreateTableRequest ;
5250import org .apache .paimon .rest .requests .CreateViewRequest ;
53- import org .apache .paimon .rest .requests .GetPartitionsRequest ;
5451import org .apache .paimon .rest .requests .MarkDonePartitionsRequest ;
5552import org .apache .paimon .rest .requests .RenameTableRequest ;
5653import org .apache .paimon .rest .responses .AlterDatabaseResponse ;
@@ -307,16 +304,6 @@ public MockResponse dispatch(RecordedRequest request) {
307304 && "tables" .equals (resources [1 ])
308305 && resources [3 ].startsWith ("partitions" );
309306
310- boolean isDropPartitions =
311- resources .length == 5
312- && "tables" .equals (resources [1 ])
313- && "partitions" .equals (resources [3 ])
314- && "drop" .equals (resources [4 ]);
315- boolean isAlterPartitions =
316- resources .length == 5
317- && "tables" .equals (resources [1 ])
318- && "partitions" .equals (resources [3 ])
319- && "alter" .equals (resources [4 ]);
320307 boolean isMarkDonePartitions =
321308 resources .length == 5
322309 && "tables" .equals (resources [1 ])
@@ -344,10 +331,7 @@ public MockResponse dispatch(RecordedRequest request) {
344331 }
345332 }
346333 // validate partition
347- if (isPartitions
348- || isDropPartitions
349- || isAlterPartitions
350- || isMarkDonePartitions ) {
334+ if (isPartitions || isMarkDonePartitions ) {
351335 String tableName = RESTUtil .decodeString (resources [2 ]);
352336 Optional <MockResponse > error =
353337 checkTablePartitioned (
@@ -356,11 +340,7 @@ public MockResponse dispatch(RecordedRequest request) {
356340 return error .get ();
357341 }
358342 }
359- if (isDropPartitions ) {
360- return dropPartitionsHandle (identifier , restAuthParameter .data ());
361- } else if (isAlterPartitions ) {
362- return alterPartitionsHandle (identifier , restAuthParameter .data ());
363- } else if (isMarkDonePartitions ) {
343+ if (isMarkDonePartitions ) {
364344 MarkDonePartitionsRequest markDonePartitionsRequest =
365345 OBJECT_MAPPER .readValue (data , MarkDonePartitionsRequest .class );
366346 catalog .markDonePartitions (
@@ -961,15 +941,6 @@ private MockResponse partitionsApiHandle(
961941 }
962942 }
963943 return generateFinalListPartitionsResponse (parameters , partitions );
964- case "POST" :
965- CreatePartitionsRequest requestBody =
966- OBJECT_MAPPER .readValue (data , CreatePartitionsRequest .class );
967- tablePartitionsStore .put (
968- tableIdentifier .getFullName (),
969- requestBody .getPartitionSpecs ().stream ()
970- .map (partition -> spec2Partition (partition ))
971- .collect (Collectors .toList ()));
972- return new MockResponse ().setResponseCode (200 );
973944 default :
974945 return new MockResponse ().setResponseCode (404 );
975946 }
@@ -1342,67 +1313,6 @@ private boolean commitSnapshot(
13421313 }
13431314 }
13441315
1345- private MockResponse dropPartitionsHandle (Identifier identifier , String data )
1346- throws Catalog .TableNotExistException , JsonProcessingException {
1347- GetPartitionsRequest getPartitionsRequest =
1348- OBJECT_MAPPER .readValue (data , GetPartitionsRequest .class );
1349- List <Map <String , String >> partitionSpecs = getPartitionsRequest .getPartitionSpecs ();
1350- if (tableMetadataStore .containsKey (identifier .getFullName ())) {
1351- List <Partition > existPartitions = tablePartitionsStore .get (identifier .getFullName ());
1352- partitionSpecs .forEach (
1353- partition -> {
1354- for (Map .Entry <String , String > entry : partition .entrySet ()) {
1355- existPartitions .stream ()
1356- .filter (
1357- p ->
1358- p .spec ().containsKey (entry .getKey ())
1359- && p .spec ()
1360- .get (entry .getKey ())
1361- .equals (entry .getValue ()))
1362- .findFirst ()
1363- .ifPresent (
1364- existPartition ->
1365- existPartitions .remove (existPartition ));
1366- }
1367- });
1368- return new MockResponse ().setResponseCode (200 );
1369-
1370- } else {
1371- throw new Catalog .TableNotExistException (identifier );
1372- }
1373- }
1374-
1375- private MockResponse alterPartitionsHandle (Identifier identifier , String data )
1376- throws Catalog .TableNotExistException , JsonProcessingException {
1377- if (tableMetadataStore .containsKey (identifier .getFullName ())) {
1378- AlterPartitionsRequest alterPartitionsRequest =
1379- OBJECT_MAPPER .readValue (data , AlterPartitionsRequest .class );
1380- List <Partition > partitions = alterPartitionsRequest .getPartitions ();
1381- List <Partition > existPartitions = tablePartitionsStore .get (identifier .getFullName ());
1382- partitions .forEach (
1383- partition -> {
1384- for (Map .Entry <String , String > entry : partition .spec ().entrySet ()) {
1385- existPartitions .stream ()
1386- .filter (
1387- p ->
1388- p .spec ().containsKey (entry .getKey ())
1389- && p .spec ()
1390- .get (entry .getKey ())
1391- .equals (entry .getValue ()))
1392- .findFirst ()
1393- .ifPresent (
1394- existPartition ->
1395- existPartitions .remove (existPartition ));
1396- }
1397- });
1398- existPartitions .addAll (partitions );
1399- tablePartitionsStore .put (identifier .getFullName (), existPartitions );
1400- return new MockResponse ().setResponseCode (200 );
1401- } else {
1402- throw new Catalog .TableNotExistException (identifier );
1403- }
1404- }
1405-
14061316 private MockResponse mockResponse (RESTResponse response , int httpCode ) {
14071317 try {
14081318 return new MockResponse ()
0 commit comments