yuqi1129 commented on code in PR #9908:
URL: https://github.com/apache/gravitino/pull/9908#discussion_r2791658773
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -231,23 +232,40 @@ public Table createTable(
SortOrder[] sortOrders,
Index[] indexes)
throws NoSuchSchemaException, TableAlreadyExistsException {
- Schema schema = loadSchema(NameIdentifier.of(ident.namespace().levels()));
- String tableLocation = calculateTableLocation(schema, ident, properties);
-
String format = properties.getOrDefault(Table.PROPERTY_TABLE_FORMAT, null);
Preconditions.checkArgument(
format != null, "Table format must be specified in table properties");
format = format.toLowerCase(Locale.ROOT);
- Map<String, String> newProperties = Maps.newHashMap(properties);
- newProperties.put(Table.PROPERTY_LOCATION, tableLocation);
- newProperties.put(Table.PROPERTY_TABLE_FORMAT, format);
-
// Get the table operations for the specified table format.
Supplier<ManagedTableOperations> tableOpsSupplier =
tableOpsCache.get(format);
Preconditions.checkArgument(tableOpsSupplier != null, "Unsupported table
format: %s", format);
ManagedTableOperations tableOps = tableOpsSupplier.get();
+ Map<String, String> newProperties = Maps.newHashMap(properties);
+ newProperties.put(Table.PROPERTY_TABLE_FORMAT, format);
+
+ Schema schema = loadSchema(NameIdentifier.of(ident.namespace().levels()));
+ String tableLocation =
+ (String)
+ propertiesMetadata
+ .tablePropertiesMetadata()
+ .getOrDefault(properties, Table.PROPERTY_LOCATION);
+ if (StringUtils.isNotBlank(tableLocation)) {
+ newProperties.put(Table.PROPERTY_LOCATION,
ensureTrailingSlash(tableLocation));
Review Comment:
`calculateTableLocation` already contains this logic, and it's duplicated.
##########
core/src/main/java/org/apache/gravitino/catalog/ManagedTableOperations.java:
##########
@@ -537,4 +546,48 @@ int calculateColumnPosition(
throw new IllegalArgumentException("Unsupported column position: " +
position);
}
}
+
+ private void validateIndexSupport(Index[] indexes) {
Review Comment:
The following three methods can be used by other catalogs. Can you extract a
util class to handle it?
##########
core/src/main/java/org/apache/gravitino/catalog/ManagedTableOperations.java:
##########
@@ -537,4 +546,48 @@ int calculateColumnPosition(
throw new IllegalArgumentException("Unsupported column position: " +
position);
}
}
+
+ private void validateIndexSupport(Index[] indexes) {
Review Comment:
The following three methods can be used by other catalogs. Can you extract a
util class to handle it?
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -231,23 +232,40 @@ public Table createTable(
SortOrder[] sortOrders,
Index[] indexes)
throws NoSuchSchemaException, TableAlreadyExistsException {
- Schema schema = loadSchema(NameIdentifier.of(ident.namespace().levels()));
- String tableLocation = calculateTableLocation(schema, ident, properties);
-
String format = properties.getOrDefault(Table.PROPERTY_TABLE_FORMAT, null);
Preconditions.checkArgument(
format != null, "Table format must be specified in table properties");
format = format.toLowerCase(Locale.ROOT);
- Map<String, String> newProperties = Maps.newHashMap(properties);
- newProperties.put(Table.PROPERTY_LOCATION, tableLocation);
- newProperties.put(Table.PROPERTY_TABLE_FORMAT, format);
-
// Get the table operations for the specified table format.
Supplier<ManagedTableOperations> tableOpsSupplier =
tableOpsCache.get(format);
Preconditions.checkArgument(tableOpsSupplier != null, "Unsupported table
format: %s", format);
ManagedTableOperations tableOps = tableOpsSupplier.get();
+ Map<String, String> newProperties = Maps.newHashMap(properties);
+ newProperties.put(Table.PROPERTY_TABLE_FORMAT, format);
+
+ Schema schema = loadSchema(NameIdentifier.of(ident.namespace().levels()));
+ String tableLocation =
+ (String)
+ propertiesMetadata
+ .tablePropertiesMetadata()
+ .getOrDefault(properties, Table.PROPERTY_LOCATION);
+ if (StringUtils.isNotBlank(tableLocation)) {
+ newProperties.put(Table.PROPERTY_LOCATION,
ensureTrailingSlash(tableLocation));
Review Comment:
`calculateTableLocation` already contains this logic, and it's duplicated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]