Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Set;
import org.apache.iceberg.rest.Endpoint;
import org.apache.polaris.core.config.FeatureConfiguration;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.config.RealmConfig;

public class PolarisEndpoints {
// Generic table endpoints
Expand Down Expand Up @@ -77,10 +77,9 @@ public class PolarisEndpoints {
* Get the generic table endpoints. Returns GENERIC_TABLE_ENDPOINTS if ENABLE_GENERIC_TABLES is
* set to true, otherwise, returns an empty set.
*/
public static Set<Endpoint> getSupportedGenericTableEndpoints(CallContext callContext) {
public static Set<Endpoint> getSupportedGenericTableEndpoints(RealmConfig realmConfig) {
// add the generic table endpoints as supported endpoints if generic table feature is enabled.
boolean genericTableEnabled =
callContext.getRealmConfig().getConfig(FeatureConfiguration.ENABLE_GENERIC_TABLES);
boolean genericTableEnabled = realmConfig.getConfig(FeatureConfiguration.ENABLE_GENERIC_TABLES);

return genericTableEnabled ? GENERIC_TABLE_ENDPOINTS : ImmutableSet.of();
}
Expand All @@ -89,9 +88,8 @@ public static Set<Endpoint> getSupportedGenericTableEndpoints(CallContext callCo
* Get the policy store endpoints. Returns POLICY_ENDPOINTS if ENABLE_POLICY_STORE is set to true,
* otherwise, returns an empty set
*/
public static Set<Endpoint> getSupportedPolicyEndpoints(CallContext callContext) {
boolean policyStoreEnabled =
callContext.getRealmConfig().getConfig(FeatureConfiguration.ENABLE_POLICY_STORE);
public static Set<Endpoint> getSupportedPolicyEndpoints(RealmConfig realmConfig) {
boolean policyStoreEnabled = realmConfig.getConfig(FeatureConfiguration.ENABLE_POLICY_STORE);
return policyStoreEnabled ? POLICY_STORE_ENDPOINTS : ImmutableSet.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void initialize(String name, Map<String, String> properties) {
var storageConfigurationInfo = catalogEntity.getStorageConfigurationInfo();
ioImplClassName =
IcebergPropertiesValidation.determineFileIOClassName(
callContext, properties, storageConfigurationInfo);
callContext.getRealmConfig(), properties, storageConfigurationInfo);

if (ioImplClassName == null) {
LOGGER.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.apache.iceberg.rest.responses.LoadTableResponse;
import org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
import org.apache.polaris.core.auth.PolarisAuthorizer;
import org.apache.polaris.core.config.RealmConfig;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.entity.PolarisEntity;
Expand Down Expand Up @@ -135,6 +136,7 @@ public class IcebergCatalogAdapter

private final RealmContext realmContext;
private final CallContext callContext;
private final RealmConfig realmConfig;
private final CallContextCatalogFactory catalogFactory;
private final ResolutionManifestFactory resolutionManifestFactory;
private final ResolverFactory resolverFactory;
Expand All @@ -160,6 +162,7 @@ public IcebergCatalogAdapter(
CatalogHandlerUtils catalogHandlerUtils) {
this.realmContext = realmContext;
this.callContext = callContext;
this.realmConfig = callContext.getRealmConfig();
this.catalogFactory = catalogFactory;
this.resolutionManifestFactory = resolutionManifestFactory;
this.resolverFactory = resolverFactory;
Expand Down Expand Up @@ -214,7 +217,7 @@ public Response createNamespace(
CreateNamespaceRequest createNamespaceRequest,
RealmContext realmContext,
SecurityContext securityContext) {
validateIcebergProperties(callContext, createNamespaceRequest.properties());
validateIcebergProperties(realmConfig, createNamespaceRequest.properties());
return withCatalog(
securityContext,
prefix,
Expand Down Expand Up @@ -306,7 +309,7 @@ public Response updateProperties(
UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest,
RealmContext realmContext,
SecurityContext securityContext) {
validateIcebergProperties(callContext, updateNamespacePropertiesRequest.updates());
validateIcebergProperties(realmConfig, updateNamespacePropertiesRequest.updates());
Namespace ns = decodeNamespace(namespace);
UpdateNamespacePropertiesRequest revisedRequest =
UpdateNamespacePropertiesRequest.builder()
Expand Down Expand Up @@ -341,7 +344,7 @@ public Response createTable(
String accessDelegationMode,
RealmContext realmContext,
SecurityContext securityContext) {
validateIcebergProperties(callContext, createTableRequest.properties());
validateIcebergProperties(realmConfig, createTableRequest.properties());
EnumSet<AccessDelegationMode> delegationModes =
parseAccessDelegationModes(accessDelegationMode);
Namespace ns = decodeNamespace(namespace);
Expand Down Expand Up @@ -516,7 +519,7 @@ public Response updateTable(
commitTableRequest.updates().stream()
.filter(MetadataUpdate.SetProperties.class::isInstance)
.map(MetadataUpdate.SetProperties.class::cast)
.forEach(setProperties -> validateIcebergProperties(callContext, setProperties.updated()));
.forEach(setProperties -> validateIcebergProperties(realmConfig, setProperties.updated()));

UpdateTableRequest revisedRequest =
UpdateTableRequest.create(
Expand Down Expand Up @@ -547,7 +550,7 @@ public Response createView(
CreateViewRequest createViewRequest,
RealmContext realmContext,
SecurityContext securityContext) {
validateIcebergProperties(callContext, createViewRequest.properties());
validateIcebergProperties(realmConfig, createViewRequest.properties());

CreateViewRequest revisedRequest =
ImmutableCreateViewRequest.copyOf(createViewRequest)
Expand Down Expand Up @@ -695,7 +698,7 @@ public Response commitTransaction(
.flatMap(updateTableRequest -> updateTableRequest.updates().stream())
.filter(MetadataUpdate.SetProperties.class::isInstance)
.map(MetadataUpdate.SetProperties.class::cast)
.forEach(setProperties -> validateIcebergProperties(callContext, setProperties.updated()));
.forEach(setProperties -> validateIcebergProperties(realmConfig, setProperties.updated()));

CommitTransactionRequest revisedRequest =
new CommitTransactionRequest(
Expand Down Expand Up @@ -791,8 +794,8 @@ public Response getConfig(
.addAll(DEFAULT_ENDPOINTS)
.addAll(VIEW_ENDPOINTS)
.addAll(COMMIT_ENDPOINT)
.addAll(PolarisEndpoints.getSupportedGenericTableEndpoints(callContext))
.addAll(PolarisEndpoints.getSupportedPolicyEndpoints(callContext))
.addAll(PolarisEndpoints.getSupportedGenericTableEndpoints(realmConfig))
.addAll(PolarisEndpoints.getSupportedPolicyEndpoints(realmConfig))
.build())
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Map;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.exceptions.ValidationException;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.config.RealmConfig;
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -36,15 +36,14 @@ public class IcebergPropertiesValidation {
private static final Logger LOGGER = LoggerFactory.getLogger(IcebergPropertiesValidation.class);

public static void validateIcebergProperties(
@Nonnull CallContext callContext, @Nonnull Map<String, String> properties) {
determineFileIOClassName(callContext, properties, null);
@Nonnull RealmConfig realmConfig, @Nonnull Map<String, String> properties) {
determineFileIOClassName(realmConfig, properties, null);
}

public static String determineFileIOClassName(
@Nonnull CallContext callContext,
@Nonnull RealmConfig realmConfig,
@Nonnull Map<String, String> properties,
@Nullable PolarisStorageConfigurationInfo storageConfigurationInfo) {
var realmConfig = callContext.getPolarisCallContext().getRealmConfig();
var ioImpl = properties.get(CatalogProperties.FILE_IO_IMPL);

if (ioImpl != null) {
Expand Down