From a008fc725d152cb5b09822fcac781f6a53aacc11 Mon Sep 17 00:00:00 2001 From: Alexandre Dutra Date: Tue, 19 Aug 2025 12:02:48 +0200 Subject: [PATCH] Nit: add methods isExternal and isStaticFacade to CatalogEntity --- .../polaris/core/entity/CatalogEntity.java | 8 +++++ .../iceberg/IcebergCatalogHandler.java | 30 ++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java b/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java index 68f6b190e5..2e4960b3ad 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java @@ -205,11 +205,19 @@ public Catalog.TypeEnum getCatalogType() { .orElse(null); } + public boolean isExternal() { + return getCatalogType() == Catalog.TypeEnum.EXTERNAL; + } + public boolean isPassthroughFacade() { return getInternalPropertiesAsMap() .containsKey(PolarisEntityConstants.getConnectionConfigInfoPropertyName()); } + public boolean isStaticFacade() { + return isExternal() && !isPassthroughFacade(); + } + public ConnectionConfigInfoDpo getConnectionConfigInfoDpo() { String configStr = getInternalPropertiesAsMap() diff --git a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java index e0a9caff9d..b0cfc01b19 100644 --- a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java +++ b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java @@ -290,12 +290,6 @@ public CreateNamespaceResponse createNamespace(CreateNamespaceRequest request) { } } - private static boolean isStaticFacade(CatalogEntity catalog) { - return org.apache.polaris.core.admin.model.Catalog.TypeEnum.EXTERNAL.equals( - catalog.getCatalogType()) - && !catalog.isPassthroughFacade(); - } - public GetNamespaceResponse loadNamespaceMetadata(Namespace namespace) { PolarisAuthorizableOperation op = PolarisAuthorizableOperation.LOAD_NAMESPACE_METADATA; authorizeBasicNamespaceOperationOrThrow(op, namespace); @@ -369,7 +363,7 @@ public LoadTableResponse createTableDirect(Namespace namespace, CreateTableReque authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot create table on static-facade external catalogs."); } CreateTableRequest requestWithoutReservedProperties = @@ -400,7 +394,7 @@ public LoadTableResponse createTableDirectWithWriteDelegation( op, TableIdentifier.of(namespace, request.name())); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot create table on static-facade external catalogs."); } request.validate(); @@ -492,7 +486,7 @@ public LoadTableResponse createTableStaged(Namespace namespace, CreateTableReque op, TableIdentifier.of(namespace, request.name())); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot create table on static-facade external catalogs."); } TableMetadata metadata = stageTableCreateHelper(namespace, request); @@ -507,7 +501,7 @@ public LoadTableResponse createTableStagedWithWriteDelegation( op, TableIdentifier.of(namespace, request.name())); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot create table on static-facade external catalogs."); } TableIdentifier ident = TableIdentifier.of(namespace, request.name()); @@ -778,7 +772,7 @@ public LoadTableResponse updateTable( op, PolarisEntitySubType.ICEBERG_TABLE, tableIdentifier); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot update table on static-facade external catalogs."); } return catalogHandlerUtils.updateTable( @@ -791,7 +785,7 @@ public LoadTableResponse updateTableForStagedCreate( authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, tableIdentifier); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot update table on static-facade external catalogs."); } return catalogHandlerUtils.updateTable( @@ -812,7 +806,7 @@ public void dropTableWithPurge(TableIdentifier tableIdentifier) { op, PolarisEntitySubType.ICEBERG_TABLE, tableIdentifier); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot drop table on static-facade external catalogs."); } catalogHandlerUtils.purgeTable(baseCatalog, tableIdentifier); @@ -833,7 +827,7 @@ public void renameTable(RenameTableRequest request) { op, PolarisEntitySubType.ICEBERG_TABLE, request.source(), request.destination()); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot rename table on static-facade external catalogs."); } catalogHandlerUtils.renameTable(baseCatalog, request); @@ -852,7 +846,7 @@ public void commitTransaction(CommitTransactionRequest commitTransactionRequest) .map(UpdateTableRequest::identifier) .toList()); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot update table on static-facade external catalogs."); } @@ -969,7 +963,7 @@ public LoadViewResponse createView(Namespace namespace, CreateViewRequest reques op, TableIdentifier.of(namespace, request.name())); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot create view on static-facade external catalogs."); } return catalogHandlerUtils.createView(viewCatalog, namespace, request); @@ -987,7 +981,7 @@ public LoadViewResponse replaceView(TableIdentifier viewIdentifier, UpdateTableR authorizeBasicTableLikeOperationOrThrow(op, PolarisEntitySubType.ICEBERG_VIEW, viewIdentifier); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot replace view on static-facade external catalogs."); } return catalogHandlerUtils.updateView(viewCatalog, viewIdentifier, applyUpdateFilters(request)); @@ -1014,7 +1008,7 @@ public void renameView(RenameTableRequest request) { op, PolarisEntitySubType.ICEBERG_VIEW, request.source(), request.destination()); CatalogEntity catalog = getResolvedCatalogEntity(); - if (isStaticFacade(catalog)) { + if (catalog.isStaticFacade()) { throw new BadRequestException("Cannot rename view on static-facade external catalogs."); } catalogHandlerUtils.renameView(viewCatalog, request);