Skip to content
Merged
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 @@ -160,6 +160,12 @@ public IcebergCatalogHandler(
this.catalogHandlerUtils = catalogHandlerUtils;
}

private CatalogEntity getResolvedCatalogEntity() {
PolarisResolvedPathWrapper catalogPath = resolutionManifest.getResolvedReferenceCatalogEntity();
diagnostics.checkNotNull(catalogPath, "No catalog available");
return CatalogEntity.of(catalogPath.getRawLeafEntity());
}

/**
* TODO: Make the helper in org.apache.iceberg.rest.CatalogHandlers public instead of needing to
* copy/paste here.
Expand Down Expand Up @@ -200,8 +206,7 @@ public ListNamespacesResponse listNamespaces(

@Override
protected void initializeCatalog() {
CatalogEntity resolvedCatalogEntity =
CatalogEntity.of(resolutionManifest.getResolvedReferenceCatalogEntity().getRawLeafEntity());
CatalogEntity resolvedCatalogEntity = getResolvedCatalogEntity();
ConnectionConfigInfoDpo connectionConfigInfoDpo =
resolvedCatalogEntity.getConnectionConfigInfoDpo();
if (connectionConfigInfoDpo != null) {
Expand Down Expand Up @@ -363,12 +368,7 @@ public LoadTableResponse createTableDirect(Namespace namespace, CreateTableReque
TableIdentifier identifier = TableIdentifier.of(namespace, request.name());
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier);

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot create table on static-facade external catalogs.");
}
Expand Down Expand Up @@ -399,12 +399,7 @@ public LoadTableResponse createTableDirectWithWriteDelegation(
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(
op, TableIdentifier.of(namespace, request.name()));

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot create table on static-facade external catalogs.");
}
Expand Down Expand Up @@ -496,12 +491,7 @@ public LoadTableResponse createTableStaged(Namespace namespace, CreateTableReque
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(
op, TableIdentifier.of(namespace, request.name()));

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot create table on static-facade external catalogs.");
}
Expand All @@ -516,12 +506,7 @@ public LoadTableResponse createTableStagedWithWriteDelegation(
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(
op, TableIdentifier.of(namespace, request.name()));

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot create table on static-facade external catalogs.");
}
Expand Down Expand Up @@ -566,12 +551,7 @@ public boolean sendNotification(TableIdentifier identifier, NotificationRequest
authorizeBasicNamespaceOperationOrThrow(
op, Namespace.empty(), extraPassthroughNamespaces, extraPassthroughTableLikes, null);

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (catalog
.getCatalogType()
.equals(org.apache.polaris.core.admin.model.Catalog.TypeEnum.INTERNAL)) {
Expand Down Expand Up @@ -682,9 +662,8 @@ public Optional<LoadTableResponse> loadTableWithAccessDelegationIfStale(
read, PolarisEntitySubType.ICEBERG_TABLE, tableIdentifier);
}

PolarisResolvedPathWrapper catalogPath = resolutionManifest.getResolvedReferenceCatalogEntity();
diagnostics.checkNotNull(catalogPath, "No catalog available for loadTable request");
CatalogEntity catalogEntity = CatalogEntity.of(catalogPath.getRawLeafEntity());
CatalogEntity catalogEntity = getResolvedCatalogEntity();

LOGGER.info("Catalog type: {}", catalogEntity.getCatalogType());
LOGGER.info(
"allow external catalog credential vending: {}",
Expand Down Expand Up @@ -798,12 +777,7 @@ public LoadTableResponse updateTable(
authorizeBasicTableLikeOperationOrThrow(
op, PolarisEntitySubType.ICEBERG_TABLE, tableIdentifier);

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot update table on static-facade external catalogs.");
}
Expand All @@ -816,12 +790,7 @@ public LoadTableResponse updateTableForStagedCreate(
PolarisAuthorizableOperation op = PolarisAuthorizableOperation.UPDATE_TABLE_FOR_STAGED_CREATE;
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, tableIdentifier);

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot update table on static-facade external catalogs.");
}
Expand All @@ -842,12 +811,7 @@ public void dropTableWithPurge(TableIdentifier tableIdentifier) {
authorizeBasicTableLikeOperationOrThrow(
op, PolarisEntitySubType.ICEBERG_TABLE, tableIdentifier);

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot drop table on static-facade external catalogs.");
}
Expand All @@ -868,12 +832,7 @@ public void renameTable(RenameTableRequest request) {
authorizeRenameTableLikeOperationOrThrow(
op, PolarisEntitySubType.ICEBERG_TABLE, request.source(), request.destination());

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot rename table on static-facade external catalogs.");
}
Expand All @@ -892,12 +851,7 @@ public void commitTransaction(CommitTransactionRequest commitTransactionRequest)
commitTransactionRequest.tableChanges().stream()
.map(UpdateTableRequest::identifier)
.toList());
CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot update table on static-facade external catalogs.");
}
Expand Down Expand Up @@ -1014,12 +968,7 @@ public LoadViewResponse createView(Namespace namespace, CreateViewRequest reques
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(
op, TableIdentifier.of(namespace, request.name()));

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot create view on static-facade external catalogs.");
}
Expand All @@ -1037,12 +986,7 @@ public LoadViewResponse replaceView(TableIdentifier viewIdentifier, UpdateTableR
PolarisAuthorizableOperation op = PolarisAuthorizableOperation.REPLACE_VIEW;
authorizeBasicTableLikeOperationOrThrow(op, PolarisEntitySubType.ICEBERG_VIEW, viewIdentifier);

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot replace view on static-facade external catalogs.");
}
Expand All @@ -1069,12 +1013,7 @@ public void renameView(RenameTableRequest request) {
authorizeRenameTableLikeOperationOrThrow(
op, PolarisEntitySubType.ICEBERG_VIEW, request.source(), request.destination());

CatalogEntity catalog =
CatalogEntity.of(
resolutionManifest
.getResolvedReferenceCatalogEntity()
.getResolvedLeafEntity()
.getEntity());
CatalogEntity catalog = getResolvedCatalogEntity();
if (isStaticFacade(catalog)) {
throw new BadRequestException("Cannot rename view on static-facade external catalogs.");
}
Expand Down