@@ -171,6 +171,7 @@ public class IcebergCatalog extends BaseMetastoreViewCatalog
171
171
private final StorageCredentialCache storageCredentialCache ;
172
172
private final ResolverFactory resolverFactory ;
173
173
private final CallContext callContext ;
174
+ private final RealmConfig realmConfig ;
174
175
private final PolarisResolutionManifestCatalogView resolvedEntityView ;
175
176
private final CatalogEntity catalogEntity ;
176
177
private final TaskExecutor taskExecutor ;
@@ -209,6 +210,7 @@ public IcebergCatalog(
209
210
this .storageCredentialCache = storageCredentialCache ;
210
211
this .resolverFactory = resolverFactory ;
211
212
this .callContext = callContext ;
213
+ this .realmConfig = callContext .getRealmConfig ();
212
214
this .resolvedEntityView = resolvedEntityView ;
213
215
this .catalogEntity =
214
216
CatalogEntity .of (resolvedEntityView .getResolvedReferenceCatalogEntity ().getRawLeafEntity ());
@@ -256,7 +258,7 @@ public void initialize(String name, Map<String, String> properties) {
256
258
var storageConfigurationInfo = catalogEntity .getStorageConfigurationInfo ();
257
259
ioImplClassName =
258
260
IcebergPropertiesValidation .determineFileIOClassName (
259
- callContext . getRealmConfig () , properties , storageConfigurationInfo );
261
+ realmConfig , properties , storageConfigurationInfo );
260
262
261
263
if (ioImplClassName == null ) {
262
264
LOGGER .warn (
@@ -346,10 +348,8 @@ public TableOperations newTableOps(
346
348
@ Override
347
349
protected TableOperations newTableOps (TableIdentifier tableIdentifier ) {
348
350
boolean makeMetadataCurrentOnCommit =
349
- callContext
350
- .getRealmConfig ()
351
- .getConfig (
352
- BehaviorChangeConfiguration .TABLE_OPERATIONS_MAKE_METADATA_CURRENT_ON_COMMIT );
351
+ realmConfig .getConfig (
352
+ BehaviorChangeConfiguration .TABLE_OPERATIONS_MAKE_METADATA_CURRENT_ON_COMMIT );
353
353
return newTableOps (tableIdentifier , makeMetadataCurrentOnCommit );
354
354
}
355
355
@@ -488,7 +488,7 @@ private void createNamespaceInternal(
488
488
489
489
// Set / suffix
490
490
boolean requireTrailingSlash =
491
- callContext . getRealmConfig () .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
491
+ realmConfig .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
492
492
if (requireTrailingSlash && !baseLocation .endsWith ("/" )) {
493
493
baseLocation += "/" ;
494
494
}
@@ -502,9 +502,7 @@ private void createNamespaceInternal(
502
502
.setCreateTimestamp (System .currentTimeMillis ())
503
503
.setBaseLocation (baseLocation )
504
504
.build ();
505
- if (!callContext
506
- .getRealmConfig ()
507
- .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
505
+ if (!realmConfig .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
508
506
LOGGER .debug ("Validating no overlap for {} with sibling tables or namespaces" , namespace );
509
507
validateNoLocationOverlap (entity , resolvedParent .getRawFullPath ());
510
508
} else {
@@ -641,9 +639,7 @@ public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyExcept
641
639
PolarisEntity .toCoreList (catalogPath ),
642
640
leafEntity ,
643
641
Map .of (),
644
- callContext
645
- .getRealmConfig ()
646
- .getConfig (FeatureConfiguration .CLEANUP_ON_NAMESPACE_DROP ));
642
+ realmConfig .getConfig (FeatureConfiguration .CLEANUP_ON_NAMESPACE_DROP ));
647
643
648
644
if (!dropEntityResult .isSuccess () && dropEntityResult .failedBecauseNotEmpty ()) {
649
645
throw new NamespaceNotEmptyException ("Namespace %s is not empty" , namespace );
@@ -668,9 +664,7 @@ public boolean setProperties(Namespace namespace, Map<String, String> properties
668
664
PolarisEntity updatedEntity =
669
665
new PolarisEntity .Builder (entity ).setProperties (newProperties ).build ();
670
666
671
- if (!callContext
672
- .getRealmConfig ()
673
- .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
667
+ if (!realmConfig .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
674
668
LOGGER .debug ("Validating no overlap with sibling tables or namespaces" );
675
669
validateNoLocationOverlap (
676
670
NamespaceEntity .of (updatedEntity ), resolvedEntities .getRawParentPath ());
@@ -874,7 +868,6 @@ private String buildPrefixedLocation(TableIdentifier tableIdentifier) {
874
868
*/
875
869
private String applyDefaultLocationObjectStoragePrefix (
876
870
TableIdentifier tableIdentifier , String location ) {
877
- RealmConfig realmConfig = callContext .getRealmConfig ();
878
871
boolean prefixEnabled =
879
872
realmConfig .getConfig (
880
873
FeatureConfiguration .DEFAULT_LOCATION_OBJECT_STORAGE_PREFIX_ENABLED , catalogEntity );
@@ -1007,17 +1000,14 @@ private void validateLocationsForTableLike(
1007
1000
PolarisResolvedPathWrapper resolvedStorageEntity ) {
1008
1001
Optional <PolarisStorageConfigurationInfo > optStorageConfiguration =
1009
1002
PolarisStorageConfigurationInfo .forEntityPath (
1010
- callContext . getRealmConfig () , resolvedStorageEntity .getRawFullPath ());
1003
+ realmConfig , resolvedStorageEntity .getRawFullPath ());
1011
1004
1012
1005
optStorageConfiguration .ifPresentOrElse (
1013
1006
storageConfigInfo -> {
1014
1007
Map <String , Map <PolarisStorageActions , PolarisStorageIntegration .ValidationResult >>
1015
1008
validationResults =
1016
1009
InMemoryStorageIntegration .validateSubpathsOfAllowedLocations (
1017
- callContext .getRealmConfig (),
1018
- storageConfigInfo ,
1019
- Set .of (PolarisStorageActions .ALL ),
1020
- locations );
1010
+ realmConfig , storageConfigInfo , Set .of (PolarisStorageActions .ALL ), locations );
1021
1011
validationResults
1022
1012
.values ()
1023
1013
.forEach (
@@ -1040,9 +1030,7 @@ private void validateLocationsForTableLike(
1040
1030
},
1041
1031
() -> {
1042
1032
List <String > allowedStorageTypes =
1043
- callContext
1044
- .getRealmConfig ()
1045
- .getConfig (FeatureConfiguration .SUPPORTED_CATALOG_STORAGE_TYPES );
1033
+ realmConfig .getConfig (FeatureConfiguration .SUPPORTED_CATALOG_STORAGE_TYPES );
1046
1034
if (!allowedStorageTypes .contains (StorageConfigInfo .StorageTypeEnum .FILE .name ())) {
1047
1035
List <String > invalidLocations =
1048
1036
locations .stream ()
@@ -1068,13 +1056,9 @@ private void validateNoLocationOverlap(
1068
1056
String location ,
1069
1057
PolarisEntity entity ) {
1070
1058
boolean validateViewOverlap =
1071
- callContext
1072
- .getRealmConfig ()
1073
- .getConfig (BehaviorChangeConfiguration .VALIDATE_VIEW_LOCATION_OVERLAP );
1059
+ realmConfig .getConfig (BehaviorChangeConfiguration .VALIDATE_VIEW_LOCATION_OVERLAP );
1074
1060
1075
- if (callContext
1076
- .getRealmConfig ()
1077
- .getConfig (FeatureConfiguration .ALLOW_TABLE_LOCATION_OVERLAP , catalog )) {
1061
+ if (realmConfig .getConfig (FeatureConfiguration .ALLOW_TABLE_LOCATION_OVERLAP , catalog )) {
1078
1062
LOGGER .debug ("Skipping location overlap validation for identifier '{}'" , identifier );
1079
1063
} else if (validateViewOverlap
1080
1064
|| entity .getSubType ().equals (PolarisEntitySubType .ICEBERG_TABLE )) {
@@ -1108,7 +1092,7 @@ private <T extends PolarisEntity & LocationBasedEntity> void validateNoLocationO
1108
1092
1109
1093
// Attempt to directly query for siblings
1110
1094
boolean useOptimizedSiblingCheck =
1111
- callContext . getRealmConfig () .getConfig (FeatureConfiguration .OPTIMIZED_SIBLING_CHECK );
1095
+ realmConfig .getConfig (FeatureConfiguration .OPTIMIZED_SIBLING_CHECK );
1112
1096
if (useOptimizedSiblingCheck ) {
1113
1097
Optional <Optional <String >> directSiblingCheckResult =
1114
1098
getMetaStoreManager ().hasOverlappingSiblings (callContext .getPolarisCallContext (), entity );
@@ -2018,12 +2002,9 @@ protected void refreshFromMetadataLocation(
2018
2002
}
2019
2003
2020
2004
private void validateMetadataFileInTableDir (TableIdentifier identifier , TableMetadata metadata ) {
2021
- boolean allowEscape =
2022
- callContext .getRealmConfig ().getConfig (FeatureConfiguration .ALLOW_EXTERNAL_TABLE_LOCATION );
2005
+ boolean allowEscape = realmConfig .getConfig (FeatureConfiguration .ALLOW_EXTERNAL_TABLE_LOCATION );
2023
2006
if (!allowEscape
2024
- && !callContext
2025
- .getRealmConfig ()
2026
- .getConfig (FeatureConfiguration .ALLOW_EXTERNAL_METADATA_FILE_LOCATION )) {
2007
+ && !realmConfig .getConfig (FeatureConfiguration .ALLOW_EXTERNAL_METADATA_FILE_LOCATION )) {
2027
2008
LOGGER .debug (
2028
2009
"Validating base location {} for table {} in metadata file {}" ,
2029
2010
metadata .location (),
@@ -2223,7 +2204,7 @@ private void createTableLike(
2223
2204
IcebergTableLikeEntity icebergTableLikeEntity = IcebergTableLikeEntity .of (entity );
2224
2205
// Set / suffix
2225
2206
boolean requireTrailingSlash =
2226
- callContext . getRealmConfig () .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
2207
+ realmConfig .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
2227
2208
if (requireTrailingSlash
2228
2209
&& icebergTableLikeEntity .getBaseLocation () != null
2229
2210
&& !icebergTableLikeEntity .getBaseLocation ().endsWith ("/" )) {
@@ -2288,7 +2269,7 @@ private void updateTableLike(TableIdentifier identifier, PolarisEntity entity) {
2288
2269
2289
2270
// Set / suffix
2290
2271
boolean requireTrailingSlash =
2291
- callContext . getRealmConfig () .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
2272
+ realmConfig .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
2292
2273
if (requireTrailingSlash
2293
2274
&& icebergTableLikeEntity .getBaseLocation () != null
2294
2275
&& !icebergTableLikeEntity .getBaseLocation ().endsWith ("/" )) {
@@ -2348,9 +2329,7 @@ private void updateTableLike(TableIdentifier identifier, PolarisEntity entity) {
2348
2329
// Check that purge is enabled, if it is set:
2349
2330
if (catalogPath != null && !catalogPath .isEmpty () && purge ) {
2350
2331
boolean dropWithPurgeEnabled =
2351
- callContext
2352
- .getRealmConfig ()
2353
- .getConfig (FeatureConfiguration .DROP_WITH_PURGE_ENABLED , catalogEntity );
2332
+ realmConfig .getConfig (FeatureConfiguration .DROP_WITH_PURGE_ENABLED , catalogEntity );
2354
2333
if (!dropWithPurgeEnabled ) {
2355
2334
throw new ForbiddenException (
2356
2335
String .format (
@@ -2575,8 +2554,6 @@ protected FileIO loadFileIO(String ioImpl, Map<String, String> properties) {
2575
2554
}
2576
2555
2577
2556
private int getMaxMetadataRefreshRetries () {
2578
- return callContext
2579
- .getRealmConfig ()
2580
- .getConfig (FeatureConfiguration .MAX_METADATA_REFRESH_RETRIES );
2557
+ return realmConfig .getConfig (FeatureConfiguration .MAX_METADATA_REFRESH_RETRIES );
2581
2558
}
2582
2559
}
0 commit comments