36
36
import org .apache .paimon .rest .exceptions .BadRequestException ;
37
37
import org .apache .paimon .rest .exceptions .ForbiddenException ;
38
38
import org .apache .paimon .rest .exceptions .NoSuchResourceException ;
39
+ import org .apache .paimon .rest .exceptions .NotImplementedException ;
39
40
import org .apache .paimon .rest .exceptions .ServiceFailureException ;
40
41
import org .apache .paimon .rest .requests .AlterDatabaseRequest ;
41
42
import org .apache .paimon .rest .requests .AlterPartitionsRequest ;
84
85
import java .util .Set ;
85
86
import java .util .concurrent .ScheduledExecutorService ;
86
87
87
- import static org .apache .paimon .CoreOptions .METASTORE_PARTITIONED_TABLE ;
88
88
import static org .apache .paimon .CoreOptions .createCommitUser ;
89
89
import static org .apache .paimon .catalog .CatalogUtils .checkNotBranch ;
90
90
import static org .apache .paimon .catalog .CatalogUtils .checkNotSystemDatabase ;
@@ -392,7 +392,7 @@ public void alterTable(
392
392
throw new ColumnAlreadyExistException (identifier , e .resourceName ());
393
393
} catch (ForbiddenException e ) {
394
394
throw new TableNoPermissionException (identifier , e );
395
- } catch (org . apache . paimon . rest . exceptions . UnsupportedOperationException e ) {
395
+ } catch (NotImplementedException e ) {
396
396
throw new UnsupportedOperationException (e .getMessage ());
397
397
} catch (ServiceFailureException e ) {
398
398
throw new IllegalStateException (e .getMessage ());
@@ -422,38 +422,35 @@ public void dropTable(Identifier identifier, boolean ignoreIfNotExists)
422
422
@ Override
423
423
public void createPartitions (Identifier identifier , List <Map <String , String >> partitions )
424
424
throws TableNotExistException {
425
- Table table = getTable (identifier );
426
- if (isMetaStorePartitionedTable (table )) {
427
- try {
428
- CreatePartitionsRequest request = new CreatePartitionsRequest (partitions );
429
- client .post (
430
- resourcePaths .partitions (
431
- identifier .getDatabaseName (), identifier .getTableName ()),
432
- request ,
433
- headers ());
434
- } catch (NoSuchResourceException e ) {
435
- throw new TableNotExistException (identifier );
436
- }
425
+ try {
426
+ CreatePartitionsRequest request = new CreatePartitionsRequest (partitions );
427
+ client .post (
428
+ resourcePaths .partitions (
429
+ identifier .getDatabaseName (), identifier .getTableName ()),
430
+ request ,
431
+ headers ());
432
+ } catch (NoSuchResourceException e ) {
433
+ throw new TableNotExistException (identifier );
434
+ } catch (NotImplementedException ignored ) {
435
+ // not a metastore partitioned table
437
436
}
438
437
}
439
438
440
439
@ Override
441
440
public void dropPartitions (Identifier identifier , List <Map <String , String >> partitions )
442
441
throws TableNotExistException {
443
- Table table = getTable (identifier );
444
- if (isMetaStorePartitionedTable (table )) {
445
- try {
446
- DropPartitionsRequest request = new DropPartitionsRequest (partitions );
447
- client .post (
448
- resourcePaths .dropPartitions (
449
- identifier .getDatabaseName (), identifier .getTableName ()),
450
- request ,
451
- headers ());
452
- } catch (NoSuchResourceException e ) {
453
- throw new TableNotExistException (identifier );
454
- }
455
- } else {
456
- FileStoreTable fileStoreTable = (FileStoreTable ) table ;
442
+ try {
443
+ DropPartitionsRequest request = new DropPartitionsRequest (partitions );
444
+ client .post (
445
+ resourcePaths .dropPartitions (
446
+ identifier .getDatabaseName (), identifier .getTableName ()),
447
+ request ,
448
+ headers ());
449
+ } catch (NoSuchResourceException e ) {
450
+ throw new TableNotExistException (identifier );
451
+ } catch (NotImplementedException ignored ) {
452
+ // not a metastore partitioned table
453
+ FileStoreTable fileStoreTable = (FileStoreTable ) getTable (identifier );
457
454
try (FileStoreCommit commit =
458
455
fileStoreTable
459
456
.store ()
@@ -468,65 +465,58 @@ public void dropPartitions(Identifier identifier, List<Map<String, String>> part
468
465
@ Override
469
466
public void alterPartitions (Identifier identifier , List <Partition > partitions )
470
467
throws TableNotExistException {
471
- Table table = getTable (identifier );
472
- if (isMetaStorePartitionedTable (table )) {
473
- try {
474
- AlterPartitionsRequest request = new AlterPartitionsRequest (partitions );
475
- client .post (
476
- resourcePaths .alterPartitions (
477
- identifier .getDatabaseName (), identifier .getTableName ()),
478
- request ,
479
- headers ());
480
- } catch (NoSuchResourceException e ) {
481
- throw new TableNotExistException (identifier );
482
- }
468
+ try {
469
+ AlterPartitionsRequest request = new AlterPartitionsRequest (partitions );
470
+ client .post (
471
+ resourcePaths .alterPartitions (
472
+ identifier .getDatabaseName (), identifier .getTableName ()),
473
+ request ,
474
+ headers ());
475
+ } catch (NoSuchResourceException e ) {
476
+ throw new TableNotExistException (identifier );
477
+ } catch (NotImplementedException ignored ) {
478
+ // not a metastore partitioned table
483
479
}
484
480
}
485
481
486
482
@ Override
487
483
public void markDonePartitions (Identifier identifier , List <Map <String , String >> partitions )
488
484
throws TableNotExistException {
489
- Table table = getTable (identifier );
490
- if (isMetaStorePartitionedTable (table )) {
491
- try {
492
- MarkDonePartitionsRequest request = new MarkDonePartitionsRequest (partitions );
493
- client .post (
494
- resourcePaths .markDonePartitions (
495
- identifier .getDatabaseName (), identifier .getTableName ()),
496
- request ,
497
- headers ());
498
- } catch (NoSuchResourceException e ) {
499
- throw new TableNotExistException (identifier );
500
- }
485
+ try {
486
+ MarkDonePartitionsRequest request = new MarkDonePartitionsRequest (partitions );
487
+ client .post (
488
+ resourcePaths .markDonePartitions (
489
+ identifier .getDatabaseName (), identifier .getTableName ()),
490
+ request ,
491
+ headers ());
492
+ } catch (NoSuchResourceException e ) {
493
+ throw new TableNotExistException (identifier );
494
+ } catch (NotImplementedException ignored ) {
495
+ // not a metastore partitioned table
501
496
}
502
497
}
503
498
504
499
@ Override
505
500
public List <Partition > listPartitions (Identifier identifier ) throws TableNotExistException {
506
- Table table = getTable (identifier );
507
- if (!isMetaStorePartitionedTable (table )) {
508
- return listPartitionsFromFileSystem (table );
509
- }
510
-
511
- ListPartitionsResponse response ;
512
501
try {
513
- response =
502
+ ListPartitionsResponse response =
514
503
client .get (
515
504
resourcePaths .partitions (
516
505
identifier .getDatabaseName (), identifier .getTableName ()),
517
506
ListPartitionsResponse .class ,
518
507
headers ());
508
+ if (response == null || response .getPartitions () == null ) {
509
+ return Collections .emptyList ();
510
+ }
511
+ return response .getPartitions ();
519
512
} catch (NoSuchResourceException e ) {
520
513
throw new TableNotExistException (identifier );
521
514
} catch (ForbiddenException e ) {
522
515
throw new TableNoPermissionException (identifier , e );
516
+ } catch (NotImplementedException e ) {
517
+ // not a metastore partitioned table
518
+ return listPartitionsFromFileSystem (getTable (identifier ));
523
519
}
524
-
525
- if (response == null || response .getPartitions () == null ) {
526
- return Collections .emptyList ();
527
- }
528
-
529
- return response .getPartitions ();
530
520
}
531
521
532
522
@ Override
@@ -626,11 +616,6 @@ public void close() throws Exception {
626
616
}
627
617
}
628
618
629
- private boolean isMetaStorePartitionedTable (Table table ) {
630
- Options options = Options .fromMap (table .options ());
631
- return Boolean .TRUE .equals (options .get (METASTORE_PARTITIONED_TABLE ));
632
- }
633
-
634
619
private Map <String , String > headers () {
635
620
return catalogAuth .getHeaders ();
636
621
}
0 commit comments