flyingImer commented on code in PR #4506:
URL: https://github.com/apache/polaris/pull/4506#discussion_r3282912021
##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java:
##########
@@ -337,6 +367,64 @@ public Table registerTable(TableIdentifier identifier,
String metadataFileLocati
return new BaseTable(ops, fullTableName(name(), identifier),
metricsReporter());
}
+ private Table overwriteRegisteredTable(
+ TableIdentifier identifier, String metadataFileLocation, String
locationDir) {
+ PolarisResolvedPathWrapper resolvedPath =
+ resolvedEntityView.getPassthroughResolvedPath(
+ ResolvedPathKey.ofTableLike(identifier),
PolarisEntitySubType.ANY_SUBTYPE);
+ if (resolvedPath == null || resolvedPath.getRawLeafEntity() == null) {
+ throw new NoSuchTableException("Table does not exist: %s", identifier);
+ }
+
+ validateLocationForTableLike(identifier, metadataFileLocation,
resolvedPath);
+
+ FileIO fileIO =
+ loadFileIOForTableLike(
+ identifier,
+ Set.of(locationDir),
+ resolvedPath,
+ new HashMap<>(tableDefaultProperties),
+ Set.of(PolarisStorageActions.READ, PolarisStorageActions.LIST));
+
+ TableMetadata metadata = TableMetadataParser.read(fileIO,
metadataFileLocation);
+ validateMetadataFileInTableDir(identifier, metadata);
+
+ List<PolarisEntity> resolvedNamespace = resolvedPath.getRawParentPath();
+ var tableLocations = StorageUtil.getLocationsUsedByTable(metadata);
+ CatalogUtils.validateLocationsForTableLike(
+ realmConfig, identifier, tableLocations, resolvedPath);
+ tableLocations.forEach(
+ location ->
+ validateNoLocationOverlap(
+ catalogEntity,
+ identifier,
+ resolvedNamespace,
+ location,
+ resolvedPath.getRawLeafEntity()));
+
+ PolarisEntity rawEntity = resolvedPath.getRawLeafEntity();
+ if (rawEntity.getSubType() != PolarisEntitySubType.ICEBERG_TABLE) {
+ throw alreadyExistsExceptionForTableLikeEntity(identifier,
rawEntity.getSubType());
+ }
+
+ IcebergTableLikeEntity existingEntity =
IcebergTableLikeEntity.of(rawEntity);
+ if (existingEntity == null) {
+ throw new NoSuchTableException("Table does not exist: %s", identifier);
+ }
+
+ Map<String, String> storedProperties =
buildTableMetadataPropertiesMap(metadata);
+ IcebergTableLikeEntity updatedEntity =
+ new IcebergTableLikeEntity.Builder(existingEntity)
+ .setInternalProperties(storedProperties)
+ .setMetadataLocation(metadataFileLocation)
Review Comment:
The overwrite path updates metadata-location and internal properties but
doesn't call .setBaseLocation(metadata.location()) . So if the new metadata
points at a different table location, the entity's stored base drifts. The
normal commit path (line ~1612) does update it. Overlap checks and
credential-vending scope depend on this being current.
##########
extensions/auth/ranger/impl/src/main/java/org/apache/polaris/extension/auth/ranger/RangerPolarisOperationSemantics.java:
##########
@@ -165,6 +166,10 @@ enum ResolvedPathRooting {
RBAC_SEMANTICS_BY_OPERATION.put(
PolarisAuthorizableOperation.REGISTER_TABLE,
new RangerPolarisOperationSemantics(toSet(TABLE_CREATE), null,
ResolvedPathRooting.ROOT));
+ RBAC_SEMANTICS_BY_OPERATION.put(
Review Comment:
@adutra do you see this being a spec mapping issue? if so, I feel we should
list out the mapping (your effort) in our docs, to set up a good contract.
--
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]