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..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,12 +220,15 @@ 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 +337,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 =