@@ -171,6 +171,7 @@ public class IcebergCatalog extends BaseMetastoreViewCatalog
171171 private final StorageCredentialCache storageCredentialCache ;
172172 private final ResolverFactory resolverFactory ;
173173 private final CallContext callContext ;
174+ private final RealmConfig realmConfig ;
174175 private final PolarisResolutionManifestCatalogView resolvedEntityView ;
175176 private final CatalogEntity catalogEntity ;
176177 private final TaskExecutor taskExecutor ;
@@ -209,6 +210,7 @@ public IcebergCatalog(
209210 this .storageCredentialCache = storageCredentialCache ;
210211 this .resolverFactory = resolverFactory ;
211212 this .callContext = callContext ;
213+ this .realmConfig = callContext .getRealmConfig ();
212214 this .resolvedEntityView = resolvedEntityView ;
213215 this .catalogEntity =
214216 CatalogEntity .of (resolvedEntityView .getResolvedReferenceCatalogEntity ().getRawLeafEntity ());
@@ -256,7 +258,7 @@ public void initialize(String name, Map<String, String> properties) {
256258 var storageConfigurationInfo = catalogEntity .getStorageConfigurationInfo ();
257259 ioImplClassName =
258260 IcebergPropertiesValidation .determineFileIOClassName (
259- callContext . getRealmConfig () , properties , storageConfigurationInfo );
261+ realmConfig , properties , storageConfigurationInfo );
260262
261263 if (ioImplClassName == null ) {
262264 LOGGER .warn (
@@ -346,10 +348,8 @@ public TableOperations newTableOps(
346348 @ Override
347349 protected TableOperations newTableOps (TableIdentifier tableIdentifier ) {
348350 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 );
353353 return newTableOps (tableIdentifier , makeMetadataCurrentOnCommit );
354354 }
355355
@@ -488,7 +488,7 @@ private void createNamespaceInternal(
488488
489489 // Set / suffix
490490 boolean requireTrailingSlash =
491- callContext . getRealmConfig () .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
491+ realmConfig .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
492492 if (requireTrailingSlash && !baseLocation .endsWith ("/" )) {
493493 baseLocation += "/" ;
494494 }
@@ -502,9 +502,7 @@ private void createNamespaceInternal(
502502 .setCreateTimestamp (System .currentTimeMillis ())
503503 .setBaseLocation (baseLocation )
504504 .build ();
505- if (!callContext
506- .getRealmConfig ()
507- .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
505+ if (!realmConfig .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
508506 LOGGER .debug ("Validating no overlap for {} with sibling tables or namespaces" , namespace );
509507 validateNoLocationOverlap (entity , resolvedParent .getRawFullPath ());
510508 } else {
@@ -641,9 +639,7 @@ public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyExcept
641639 PolarisEntity .toCoreList (catalogPath ),
642640 leafEntity ,
643641 Map .of (),
644- callContext
645- .getRealmConfig ()
646- .getConfig (FeatureConfiguration .CLEANUP_ON_NAMESPACE_DROP ));
642+ realmConfig .getConfig (FeatureConfiguration .CLEANUP_ON_NAMESPACE_DROP ));
647643
648644 if (!dropEntityResult .isSuccess () && dropEntityResult .failedBecauseNotEmpty ()) {
649645 throw new NamespaceNotEmptyException ("Namespace %s is not empty" , namespace );
@@ -668,9 +664,7 @@ public boolean setProperties(Namespace namespace, Map<String, String> properties
668664 PolarisEntity updatedEntity =
669665 new PolarisEntity .Builder (entity ).setProperties (newProperties ).build ();
670666
671- if (!callContext
672- .getRealmConfig ()
673- .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
667+ if (!realmConfig .getConfig (FeatureConfiguration .ALLOW_NAMESPACE_LOCATION_OVERLAP )) {
674668 LOGGER .debug ("Validating no overlap with sibling tables or namespaces" );
675669 validateNoLocationOverlap (
676670 NamespaceEntity .of (updatedEntity ), resolvedEntities .getRawParentPath ());
@@ -874,7 +868,6 @@ private String buildPrefixedLocation(TableIdentifier tableIdentifier) {
874868 */
875869 private String applyDefaultLocationObjectStoragePrefix (
876870 TableIdentifier tableIdentifier , String location ) {
877- RealmConfig realmConfig = callContext .getRealmConfig ();
878871 boolean prefixEnabled =
879872 realmConfig .getConfig (
880873 FeatureConfiguration .DEFAULT_LOCATION_OBJECT_STORAGE_PREFIX_ENABLED , catalogEntity );
@@ -1007,17 +1000,14 @@ private void validateLocationsForTableLike(
10071000 PolarisResolvedPathWrapper resolvedStorageEntity ) {
10081001 Optional <PolarisStorageConfigurationInfo > optStorageConfiguration =
10091002 PolarisStorageConfigurationInfo .forEntityPath (
1010- callContext . getRealmConfig () , resolvedStorageEntity .getRawFullPath ());
1003+ realmConfig , resolvedStorageEntity .getRawFullPath ());
10111004
10121005 optStorageConfiguration .ifPresentOrElse (
10131006 storageConfigInfo -> {
10141007 Map <String , Map <PolarisStorageActions , PolarisStorageIntegration .ValidationResult >>
10151008 validationResults =
10161009 InMemoryStorageIntegration .validateSubpathsOfAllowedLocations (
1017- callContext .getRealmConfig (),
1018- storageConfigInfo ,
1019- Set .of (PolarisStorageActions .ALL ),
1020- locations );
1010+ realmConfig , storageConfigInfo , Set .of (PolarisStorageActions .ALL ), locations );
10211011 validationResults
10221012 .values ()
10231013 .forEach (
@@ -1040,9 +1030,7 @@ private void validateLocationsForTableLike(
10401030 },
10411031 () -> {
10421032 List <String > allowedStorageTypes =
1043- callContext
1044- .getRealmConfig ()
1045- .getConfig (FeatureConfiguration .SUPPORTED_CATALOG_STORAGE_TYPES );
1033+ realmConfig .getConfig (FeatureConfiguration .SUPPORTED_CATALOG_STORAGE_TYPES );
10461034 if (!allowedStorageTypes .contains (StorageConfigInfo .StorageTypeEnum .FILE .name ())) {
10471035 List <String > invalidLocations =
10481036 locations .stream ()
@@ -1068,13 +1056,9 @@ private void validateNoLocationOverlap(
10681056 String location ,
10691057 PolarisEntity entity ) {
10701058 boolean validateViewOverlap =
1071- callContext
1072- .getRealmConfig ()
1073- .getConfig (BehaviorChangeConfiguration .VALIDATE_VIEW_LOCATION_OVERLAP );
1059+ realmConfig .getConfig (BehaviorChangeConfiguration .VALIDATE_VIEW_LOCATION_OVERLAP );
10741060
1075- if (callContext
1076- .getRealmConfig ()
1077- .getConfig (FeatureConfiguration .ALLOW_TABLE_LOCATION_OVERLAP , catalog )) {
1061+ if (realmConfig .getConfig (FeatureConfiguration .ALLOW_TABLE_LOCATION_OVERLAP , catalog )) {
10781062 LOGGER .debug ("Skipping location overlap validation for identifier '{}'" , identifier );
10791063 } else if (validateViewOverlap
10801064 || entity .getSubType ().equals (PolarisEntitySubType .ICEBERG_TABLE )) {
@@ -1108,7 +1092,7 @@ private <T extends PolarisEntity & LocationBasedEntity> void validateNoLocationO
11081092
11091093 // Attempt to directly query for siblings
11101094 boolean useOptimizedSiblingCheck =
1111- callContext . getRealmConfig () .getConfig (FeatureConfiguration .OPTIMIZED_SIBLING_CHECK );
1095+ realmConfig .getConfig (FeatureConfiguration .OPTIMIZED_SIBLING_CHECK );
11121096 if (useOptimizedSiblingCheck ) {
11131097 Optional <Optional <String >> directSiblingCheckResult =
11141098 getMetaStoreManager ().hasOverlappingSiblings (callContext .getPolarisCallContext (), entity );
@@ -2018,12 +2002,9 @@ protected void refreshFromMetadataLocation(
20182002 }
20192003
20202004 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 );
20232006 if (!allowEscape
2024- && !callContext
2025- .getRealmConfig ()
2026- .getConfig (FeatureConfiguration .ALLOW_EXTERNAL_METADATA_FILE_LOCATION )) {
2007+ && !realmConfig .getConfig (FeatureConfiguration .ALLOW_EXTERNAL_METADATA_FILE_LOCATION )) {
20272008 LOGGER .debug (
20282009 "Validating base location {} for table {} in metadata file {}" ,
20292010 metadata .location (),
@@ -2223,7 +2204,7 @@ private void createTableLike(
22232204 IcebergTableLikeEntity icebergTableLikeEntity = IcebergTableLikeEntity .of (entity );
22242205 // Set / suffix
22252206 boolean requireTrailingSlash =
2226- callContext . getRealmConfig () .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
2207+ realmConfig .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
22272208 if (requireTrailingSlash
22282209 && icebergTableLikeEntity .getBaseLocation () != null
22292210 && !icebergTableLikeEntity .getBaseLocation ().endsWith ("/" )) {
@@ -2288,7 +2269,7 @@ private void updateTableLike(TableIdentifier identifier, PolarisEntity entity) {
22882269
22892270 // Set / suffix
22902271 boolean requireTrailingSlash =
2291- callContext . getRealmConfig () .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
2272+ realmConfig .getConfig (FeatureConfiguration .ADD_TRAILING_SLASH_TO_LOCATION );
22922273 if (requireTrailingSlash
22932274 && icebergTableLikeEntity .getBaseLocation () != null
22942275 && !icebergTableLikeEntity .getBaseLocation ().endsWith ("/" )) {
@@ -2348,9 +2329,7 @@ private void updateTableLike(TableIdentifier identifier, PolarisEntity entity) {
23482329 // Check that purge is enabled, if it is set:
23492330 if (catalogPath != null && !catalogPath .isEmpty () && purge ) {
23502331 boolean dropWithPurgeEnabled =
2351- callContext
2352- .getRealmConfig ()
2353- .getConfig (FeatureConfiguration .DROP_WITH_PURGE_ENABLED , catalogEntity );
2332+ realmConfig .getConfig (FeatureConfiguration .DROP_WITH_PURGE_ENABLED , catalogEntity );
23542333 if (!dropWithPurgeEnabled ) {
23552334 throw new ForbiddenException (
23562335 String .format (
@@ -2575,8 +2554,6 @@ protected FileIO loadFileIO(String ioImpl, Map<String, String> properties) {
25752554 }
25762555
25772556 private int getMaxMetadataRefreshRetries () {
2578- return callContext
2579- .getRealmConfig ()
2580- .getConfig (FeatureConfiguration .MAX_METADATA_REFRESH_RETRIES );
2557+ return realmConfig .getConfig (FeatureConfiguration .MAX_METADATA_REFRESH_RETRIES );
25812558 }
25822559}
0 commit comments