in polaris-core/src/main/java/org/apache/polaris/core/persistence/resolver/Resolver.java [828:872]
private ResolverStatus resolveReferenceCatalog(
@Nonnull List<ResolvedPolarisEntity> toValidate, @Nonnull String referenceCatalogName) {
// resolve the catalog
this.resolvedReferenceCatalog =
this.resolveByName(toValidate, PolarisEntityType.CATALOG, referenceCatalogName);
// error out if we couldn't find it
if (this.resolvedReferenceCatalog == null
|| this.resolvedReferenceCatalog.getEntity().isDropped()) {
return new ResolverStatus(PolarisEntityType.CATALOG, this.referenceCatalogName);
}
// determine the set of catalog roles which have been activated
long catalogId = this.resolvedReferenceCatalog.getEntity().getId();
for (ResolvedPolarisEntity principalRole : resolvedCallerPrincipalRoles) {
for (PolarisGrantRecord grantRecord : principalRole.getGrantRecordsAsGrantee()) {
// the securable is a catalog role belonging to
if (grantRecord.getPrivilegeCode() == PolarisPrivilege.CATALOG_ROLE_USAGE.getCode()
&& grantRecord.getSecurableCatalogId() == catalogId) {
// the id of the catalog role
long catalogRoleId = grantRecord.getSecurableId();
// skip if it has already been added
if (!this.resolvedCatalogRoles.containsKey(catalogRoleId)) {
// see if this catalog can be resolved
ResolvedPolarisEntity catalogRole =
this.resolveById(
toValidate, PolarisEntityType.CATALOG_ROLE, catalogId, catalogRoleId);
// if found and not dropped, add it to the list of activated catalog roles
if (catalogRole != null && !catalogRole.getEntity().isDropped()) {
this.resolvedCatalogRoles.put(catalogRoleId, catalogRole);
}
}
}
}
}
if (CatalogEntity.of(this.resolvedReferenceCatalog.getEntity()).isPassthroughFacade()) {
this.isPassthroughFacade = true;
}
// all good
return new ResolverStatus(ResolverStatus.StatusEnum.SUCCESS);
}