Skip to content

Commit

Permalink
remove Preconditions.checkArgument
Browse files Browse the repository at this point in the history
  • Loading branch information
xunliu committed Jan 7, 2025
1 parent 3ad84b9 commit f8f2db9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ protected void updatePolicyByMetadataObject(
* If remove the TABLE, need to remove these the relevant policies, `{schema}.*`, `{schema}.*.*`
* <br>
* If remove the COLUMN, Only need to remove `{schema}.*.*` <br>
* If remove the PATH, Only need to remove `{path}` <br>
*/
@Override
protected void doRemoveMetadataObject(AuthorizationMetadataObject authzMetadataObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,11 @@ public static List<String> getMetadataObjectLocation(
if (schema.properties().containsKey(HiveConstants.LOCATION)) {
String defaultSchemaLocation =
schema.properties().get(HiveConstants.LOCATION);
Preconditions.checkArgument(
defaultSchemaLocation != null,
String.format("Catalog %s location is not found", ident));
locations.add(defaultSchemaLocation);
if (defaultSchemaLocation != null && !defaultSchemaLocation.isEmpty()) {
locations.add(defaultSchemaLocation);
} else {
LOG.warn("Catalog %s location is not found", ident);
}
}
}
});
Expand All @@ -435,10 +436,11 @@ public static List<String> getMetadataObjectLocation(
metalake, catalogObj.name(), "default" /*Hive default schema*/));
if (schema.properties().containsKey(HiveConstants.LOCATION)) {
String defaultSchemaLocation = schema.properties().get(HiveConstants.LOCATION);
Preconditions.checkArgument(
defaultSchemaLocation != null,
String.format("Catalog %s location is not found", ident));
locations.add(defaultSchemaLocation);
if (defaultSchemaLocation != null && !defaultSchemaLocation.isEmpty()) {
locations.add(defaultSchemaLocation);
} else {
LOG.warn("Catalog %s location is not found", ident);
}
}
}
}
Expand All @@ -448,20 +450,24 @@ public static List<String> getMetadataObjectLocation(
Schema schema = GravitinoEnv.getInstance().schemaDispatcher().loadSchema(ident);
if (schema.properties().containsKey(HiveConstants.LOCATION)) {
String schemaLocation = schema.properties().get(HiveConstants.LOCATION);
Preconditions.checkArgument(
schemaLocation != null, String.format("Schema %s location is not found", ident));
locations.add(schemaLocation);
if (schemaLocation != null && schemaLocation.isEmpty()) {
locations.add(schemaLocation);
} else {
LOG.warn("Schema %s location is not found", ident);
}
}
}
break;
case TABLE:
{
Table table = GravitinoEnv.getInstance().tableDispatcher().loadTable(ident);
if (table.properties().containsKey(HiveConstants.LOCATION)) {
String schemaLocation = table.properties().get(HiveConstants.LOCATION);
Preconditions.checkArgument(
schemaLocation != null, String.format("Table %s location is not found", ident));
locations.add(schemaLocation);
String tableLocation = table.properties().get(HiveConstants.LOCATION);
if (tableLocation != null && tableLocation.isEmpty()) {
locations.add(tableLocation);
} else {
LOG.warn("Table %s location is not found", ident);
}
}
}
break;
Expand All @@ -477,8 +483,6 @@ public static List<String> getMetadataObjectLocation(
String.format("Fileset %s location is not found", identifier));
locations.add(filesetLocation);
break;
case TOPIC:
break;
default:
throw new AuthorizationPluginException(
"The metadata object type %s is not supported get location paths.",
Expand Down

0 comments on commit f8f2db9

Please sign in to comment.