From f03eac0e3a0bcc778f5a794a3db92e8789577589 Mon Sep 17 00:00:00 2001 From: Honah J Date: Fri, 4 Apr 2025 11:20:13 -0500 Subject: [PATCH 1/2] Fix CI --- .../catalog/common/CatalogHandler.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java b/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java index 48c2391f2e..9739210b74 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java @@ -220,12 +220,16 @@ protected void authorizeBasicTableLikeOperationOrThrow( PolarisResolvedPathWrapper target = resolutionManifest.getResolvedPath(identifier, PolarisEntityType.TABLE_LIKE, subType, true); if (target == null) { - if (subType == PolarisEntitySubType.ICEBERG_TABLE) { - throw new NoSuchTableException("Table does not exist: %s", identifier); - } else if (subType == PolarisEntitySubType.GENERIC_TABLE) { - throw new NoSuchTableException("Generic table does not exist: %s", identifier); - } else { - throw new NoSuchViewException("View does not exist: %s", identifier); + + switch (subType) { + case PolarisEntitySubType.ICEBERG_TABLE: + throw new NoSuchTableException("Table does not exist: %s", identifier); + + case PolarisEntitySubType.GENERIC_TABLE: + throw new NoSuchTableException("Generic table does not exist: %s", identifier); + + default: + throw new NoSuchViewException("View does not exist: %s", identifier); } } authorizer.authorizeOrThrow( @@ -334,13 +338,20 @@ protected void authorizeRenameTableLikeOperationOrThrow( // TODO: Possibly modify the exception thrown depending on whether the caller has privileges // on the parent namespace. PolarisEntitySubType dstLeafSubType = resolutionManifest.getLeafSubType(dst); - if (dstLeafSubType == PolarisEntitySubType.ICEBERG_TABLE) { - throw new AlreadyExistsException("Cannot rename %s to %s. Table already exists", src, dst); - } else if (dstLeafSubType == PolarisEntitySubType.ICEBERG_VIEW) { - throw new AlreadyExistsException("Cannot rename %s to %s. View already exists", src, dst); - } else if (dstLeafSubType == PolarisEntitySubType.GENERIC_TABLE) { - throw new AlreadyExistsException( - "Cannot rename %s to %s. Generic table already exists", src, dst); + + switch (dstLeafSubType) { + case PolarisEntitySubType.ICEBERG_TABLE: + throw new AlreadyExistsException("Cannot rename %s to %s. Table already exists", src, dst); + + case PolarisEntitySubType.ICEBERG_VIEW: + throw new AlreadyExistsException("Cannot rename %s to %s. View already exists", src, dst); + + case PolarisEntitySubType.GENERIC_TABLE: + throw new AlreadyExistsException( + "Cannot rename %s to %s. Generic table already exists", src, dst); + + default: + break; } PolarisResolvedPathWrapper target = From 8c44b6b290c749622359c3fd5cf38856f483061e Mon Sep 17 00:00:00 2001 From: Honah J Date: Fri, 4 Apr 2025 11:21:01 -0500 Subject: [PATCH 2/2] Fix nit --- .../apache/polaris/service/catalog/common/CatalogHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java b/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java index 9739210b74..293c4c488c 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java @@ -220,7 +220,6 @@ protected void authorizeBasicTableLikeOperationOrThrow( PolarisResolvedPathWrapper target = resolutionManifest.getResolvedPath(identifier, PolarisEntityType.TABLE_LIKE, subType, true); if (target == null) { - switch (subType) { case PolarisEntitySubType.ICEBERG_TABLE: throw new NoSuchTableException("Table does not exist: %s", identifier);