@@ -160,6 +160,12 @@ public IcebergCatalogHandler(
160
160
this .catalogHandlerUtils = catalogHandlerUtils ;
161
161
}
162
162
163
+ private CatalogEntity getResolvedCatalogEntity () {
164
+ PolarisResolvedPathWrapper catalogPath = resolutionManifest .getResolvedReferenceCatalogEntity ();
165
+ diagnostics .checkNotNull (catalogPath , "No catalog available" );
166
+ return CatalogEntity .of (catalogPath .getRawLeafEntity ());
167
+ }
168
+
163
169
/**
164
170
* TODO: Make the helper in org.apache.iceberg.rest.CatalogHandlers public instead of needing to
165
171
* copy/paste here.
@@ -200,8 +206,7 @@ public ListNamespacesResponse listNamespaces(
200
206
201
207
@ Override
202
208
protected void initializeCatalog () {
203
- CatalogEntity resolvedCatalogEntity =
204
- CatalogEntity .of (resolutionManifest .getResolvedReferenceCatalogEntity ().getRawLeafEntity ());
209
+ CatalogEntity resolvedCatalogEntity = getResolvedCatalogEntity ();
205
210
ConnectionConfigInfoDpo connectionConfigInfoDpo =
206
211
resolvedCatalogEntity .getConnectionConfigInfoDpo ();
207
212
if (connectionConfigInfoDpo != null ) {
@@ -363,12 +368,7 @@ public LoadTableResponse createTableDirect(Namespace namespace, CreateTableReque
363
368
TableIdentifier identifier = TableIdentifier .of (namespace , request .name ());
364
369
authorizeCreateTableLikeUnderNamespaceOperationOrThrow (op , identifier );
365
370
366
- CatalogEntity catalog =
367
- CatalogEntity .of (
368
- resolutionManifest
369
- .getResolvedReferenceCatalogEntity ()
370
- .getResolvedLeafEntity ()
371
- .getEntity ());
371
+ CatalogEntity catalog = getResolvedCatalogEntity ();
372
372
if (isStaticFacade (catalog )) {
373
373
throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
374
374
}
@@ -399,12 +399,7 @@ public LoadTableResponse createTableDirectWithWriteDelegation(
399
399
authorizeCreateTableLikeUnderNamespaceOperationOrThrow (
400
400
op , TableIdentifier .of (namespace , request .name ()));
401
401
402
- CatalogEntity catalog =
403
- CatalogEntity .of (
404
- resolutionManifest
405
- .getResolvedReferenceCatalogEntity ()
406
- .getResolvedLeafEntity ()
407
- .getEntity ());
402
+ CatalogEntity catalog = getResolvedCatalogEntity ();
408
403
if (isStaticFacade (catalog )) {
409
404
throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
410
405
}
@@ -496,12 +491,7 @@ public LoadTableResponse createTableStaged(Namespace namespace, CreateTableReque
496
491
authorizeCreateTableLikeUnderNamespaceOperationOrThrow (
497
492
op , TableIdentifier .of (namespace , request .name ()));
498
493
499
- CatalogEntity catalog =
500
- CatalogEntity .of (
501
- resolutionManifest
502
- .getResolvedReferenceCatalogEntity ()
503
- .getResolvedLeafEntity ()
504
- .getEntity ());
494
+ CatalogEntity catalog = getResolvedCatalogEntity ();
505
495
if (isStaticFacade (catalog )) {
506
496
throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
507
497
}
@@ -516,12 +506,7 @@ public LoadTableResponse createTableStagedWithWriteDelegation(
516
506
authorizeCreateTableLikeUnderNamespaceOperationOrThrow (
517
507
op , TableIdentifier .of (namespace , request .name ()));
518
508
519
- CatalogEntity catalog =
520
- CatalogEntity .of (
521
- resolutionManifest
522
- .getResolvedReferenceCatalogEntity ()
523
- .getResolvedLeafEntity ()
524
- .getEntity ());
509
+ CatalogEntity catalog = getResolvedCatalogEntity ();
525
510
if (isStaticFacade (catalog )) {
526
511
throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
527
512
}
@@ -566,12 +551,7 @@ public boolean sendNotification(TableIdentifier identifier, NotificationRequest
566
551
authorizeBasicNamespaceOperationOrThrow (
567
552
op , Namespace .empty (), extraPassthroughNamespaces , extraPassthroughTableLikes , null );
568
553
569
- CatalogEntity catalog =
570
- CatalogEntity .of (
571
- resolutionManifest
572
- .getResolvedReferenceCatalogEntity ()
573
- .getResolvedLeafEntity ()
574
- .getEntity ());
554
+ CatalogEntity catalog = getResolvedCatalogEntity ();
575
555
if (catalog
576
556
.getCatalogType ()
577
557
.equals (org .apache .polaris .core .admin .model .Catalog .TypeEnum .INTERNAL )) {
@@ -682,9 +662,8 @@ public Optional<LoadTableResponse> loadTableWithAccessDelegationIfStale(
682
662
read , PolarisEntitySubType .ICEBERG_TABLE , tableIdentifier );
683
663
}
684
664
685
- PolarisResolvedPathWrapper catalogPath = resolutionManifest .getResolvedReferenceCatalogEntity ();
686
- diagnostics .checkNotNull (catalogPath , "No catalog available for loadTable request" );
687
- CatalogEntity catalogEntity = CatalogEntity .of (catalogPath .getRawLeafEntity ());
665
+ CatalogEntity catalogEntity = getResolvedCatalogEntity ();
666
+
688
667
LOGGER .info ("Catalog type: {}" , catalogEntity .getCatalogType ());
689
668
LOGGER .info (
690
669
"allow external catalog credential vending: {}" ,
@@ -798,12 +777,7 @@ public LoadTableResponse updateTable(
798
777
authorizeBasicTableLikeOperationOrThrow (
799
778
op , PolarisEntitySubType .ICEBERG_TABLE , tableIdentifier );
800
779
801
- CatalogEntity catalog =
802
- CatalogEntity .of (
803
- resolutionManifest
804
- .getResolvedReferenceCatalogEntity ()
805
- .getResolvedLeafEntity ()
806
- .getEntity ());
780
+ CatalogEntity catalog = getResolvedCatalogEntity ();
807
781
if (isStaticFacade (catalog )) {
808
782
throw new BadRequestException ("Cannot update table on static-facade external catalogs." );
809
783
}
@@ -816,12 +790,7 @@ public LoadTableResponse updateTableForStagedCreate(
816
790
PolarisAuthorizableOperation op = PolarisAuthorizableOperation .UPDATE_TABLE_FOR_STAGED_CREATE ;
817
791
authorizeCreateTableLikeUnderNamespaceOperationOrThrow (op , tableIdentifier );
818
792
819
- CatalogEntity catalog =
820
- CatalogEntity .of (
821
- resolutionManifest
822
- .getResolvedReferenceCatalogEntity ()
823
- .getResolvedLeafEntity ()
824
- .getEntity ());
793
+ CatalogEntity catalog = getResolvedCatalogEntity ();
825
794
if (isStaticFacade (catalog )) {
826
795
throw new BadRequestException ("Cannot update table on static-facade external catalogs." );
827
796
}
@@ -842,12 +811,7 @@ public void dropTableWithPurge(TableIdentifier tableIdentifier) {
842
811
authorizeBasicTableLikeOperationOrThrow (
843
812
op , PolarisEntitySubType .ICEBERG_TABLE , tableIdentifier );
844
813
845
- CatalogEntity catalog =
846
- CatalogEntity .of (
847
- resolutionManifest
848
- .getResolvedReferenceCatalogEntity ()
849
- .getResolvedLeafEntity ()
850
- .getEntity ());
814
+ CatalogEntity catalog = getResolvedCatalogEntity ();
851
815
if (isStaticFacade (catalog )) {
852
816
throw new BadRequestException ("Cannot drop table on static-facade external catalogs." );
853
817
}
@@ -868,12 +832,7 @@ public void renameTable(RenameTableRequest request) {
868
832
authorizeRenameTableLikeOperationOrThrow (
869
833
op , PolarisEntitySubType .ICEBERG_TABLE , request .source (), request .destination ());
870
834
871
- CatalogEntity catalog =
872
- CatalogEntity .of (
873
- resolutionManifest
874
- .getResolvedReferenceCatalogEntity ()
875
- .getResolvedLeafEntity ()
876
- .getEntity ());
835
+ CatalogEntity catalog = getResolvedCatalogEntity ();
877
836
if (isStaticFacade (catalog )) {
878
837
throw new BadRequestException ("Cannot rename table on static-facade external catalogs." );
879
838
}
@@ -892,12 +851,7 @@ public void commitTransaction(CommitTransactionRequest commitTransactionRequest)
892
851
commitTransactionRequest .tableChanges ().stream ()
893
852
.map (UpdateTableRequest ::identifier )
894
853
.toList ());
895
- CatalogEntity catalog =
896
- CatalogEntity .of (
897
- resolutionManifest
898
- .getResolvedReferenceCatalogEntity ()
899
- .getResolvedLeafEntity ()
900
- .getEntity ());
854
+ CatalogEntity catalog = getResolvedCatalogEntity ();
901
855
if (isStaticFacade (catalog )) {
902
856
throw new BadRequestException ("Cannot update table on static-facade external catalogs." );
903
857
}
@@ -1014,12 +968,7 @@ public LoadViewResponse createView(Namespace namespace, CreateViewRequest reques
1014
968
authorizeCreateTableLikeUnderNamespaceOperationOrThrow (
1015
969
op , TableIdentifier .of (namespace , request .name ()));
1016
970
1017
- CatalogEntity catalog =
1018
- CatalogEntity .of (
1019
- resolutionManifest
1020
- .getResolvedReferenceCatalogEntity ()
1021
- .getResolvedLeafEntity ()
1022
- .getEntity ());
971
+ CatalogEntity catalog = getResolvedCatalogEntity ();
1023
972
if (isStaticFacade (catalog )) {
1024
973
throw new BadRequestException ("Cannot create view on static-facade external catalogs." );
1025
974
}
@@ -1037,12 +986,7 @@ public LoadViewResponse replaceView(TableIdentifier viewIdentifier, UpdateTableR
1037
986
PolarisAuthorizableOperation op = PolarisAuthorizableOperation .REPLACE_VIEW ;
1038
987
authorizeBasicTableLikeOperationOrThrow (op , PolarisEntitySubType .ICEBERG_VIEW , viewIdentifier );
1039
988
1040
- CatalogEntity catalog =
1041
- CatalogEntity .of (
1042
- resolutionManifest
1043
- .getResolvedReferenceCatalogEntity ()
1044
- .getResolvedLeafEntity ()
1045
- .getEntity ());
989
+ CatalogEntity catalog = getResolvedCatalogEntity ();
1046
990
if (isStaticFacade (catalog )) {
1047
991
throw new BadRequestException ("Cannot replace view on static-facade external catalogs." );
1048
992
}
@@ -1069,12 +1013,7 @@ public void renameView(RenameTableRequest request) {
1069
1013
authorizeRenameTableLikeOperationOrThrow (
1070
1014
op , PolarisEntitySubType .ICEBERG_VIEW , request .source (), request .destination ());
1071
1015
1072
- CatalogEntity catalog =
1073
- CatalogEntity .of (
1074
- resolutionManifest
1075
- .getResolvedReferenceCatalogEntity ()
1076
- .getResolvedLeafEntity ()
1077
- .getEntity ());
1016
+ CatalogEntity catalog = getResolvedCatalogEntity ();
1078
1017
if (isStaticFacade (catalog )) {
1079
1018
throw new BadRequestException ("Cannot rename view on static-facade external catalogs." );
1080
1019
}
0 commit comments