Skip to content

Commit 9714ef2

Browse files
authored
Refactor CatalogHandler to comply with ErrorProne rules (#1312)
Fix the CI error after #1233
1 parent e6d1ade commit 9714ef2

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

Diff for: service/common/src/main/java/org/apache/polaris/service/catalog/common/CatalogHandler.java

+23-13
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,15 @@ protected void authorizeBasicTableLikeOperationOrThrow(
220220
PolarisResolvedPathWrapper target =
221221
resolutionManifest.getResolvedPath(identifier, PolarisEntityType.TABLE_LIKE, subType, true);
222222
if (target == null) {
223-
if (subType == PolarisEntitySubType.ICEBERG_TABLE) {
224-
throw new NoSuchTableException("Table does not exist: %s", identifier);
225-
} else if (subType == PolarisEntitySubType.GENERIC_TABLE) {
226-
throw new NoSuchTableException("Generic table does not exist: %s", identifier);
227-
} else {
228-
throw new NoSuchViewException("View does not exist: %s", identifier);
223+
switch (subType) {
224+
case PolarisEntitySubType.ICEBERG_TABLE:
225+
throw new NoSuchTableException("Table does not exist: %s", identifier);
226+
227+
case PolarisEntitySubType.GENERIC_TABLE:
228+
throw new NoSuchTableException("Generic table does not exist: %s", identifier);
229+
230+
default:
231+
throw new NoSuchViewException("View does not exist: %s", identifier);
229232
}
230233
}
231234
authorizer.authorizeOrThrow(
@@ -334,13 +337,20 @@ protected void authorizeRenameTableLikeOperationOrThrow(
334337
// TODO: Possibly modify the exception thrown depending on whether the caller has privileges
335338
// on the parent namespace.
336339
PolarisEntitySubType dstLeafSubType = resolutionManifest.getLeafSubType(dst);
337-
if (dstLeafSubType == PolarisEntitySubType.ICEBERG_TABLE) {
338-
throw new AlreadyExistsException("Cannot rename %s to %s. Table already exists", src, dst);
339-
} else if (dstLeafSubType == PolarisEntitySubType.ICEBERG_VIEW) {
340-
throw new AlreadyExistsException("Cannot rename %s to %s. View already exists", src, dst);
341-
} else if (dstLeafSubType == PolarisEntitySubType.GENERIC_TABLE) {
342-
throw new AlreadyExistsException(
343-
"Cannot rename %s to %s. Generic table already exists", src, dst);
340+
341+
switch (dstLeafSubType) {
342+
case PolarisEntitySubType.ICEBERG_TABLE:
343+
throw new AlreadyExistsException("Cannot rename %s to %s. Table already exists", src, dst);
344+
345+
case PolarisEntitySubType.ICEBERG_VIEW:
346+
throw new AlreadyExistsException("Cannot rename %s to %s. View already exists", src, dst);
347+
348+
case PolarisEntitySubType.GENERIC_TABLE:
349+
throw new AlreadyExistsException(
350+
"Cannot rename %s to %s. Generic table already exists", src, dst);
351+
352+
default:
353+
break;
344354
}
345355

346356
PolarisResolvedPathWrapper target =

0 commit comments

Comments
 (0)