-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract resolution mechanisms from service implementations
Currently all service implementations, both the Polaris admin service and the (Iceberg REST) catalog service need knowledge about the implementation details about _how exactly_ entities and their instances are managed. This is rather a persistence implementation concern, not a service implementation concern. Services should tell, if necessary, tell a properly abstracted builder which entities it will need. Another concern this change tackles is to eventually allow a more efficient data model that is suitable for horizontally scalable databases without having to use pgsql with the implicitly required serializable isolation level. This change abstracts the two related but still different entity resolution (`ResolutionManifest` and `Resolver`) via interfaces and concrete implementation classes, eliminating the hard dependency of services to concrete persistence specific implementations. Follow ups of this change shall: * Remove the dependency on "entity cache" from `Resolver` - consumers of `Resolver` unwrap those in all cases * Rather unify `ResolutionManifest` and `Resolver` - those are very tightly coupled things, doing quite some work
- Loading branch information
Showing
48 changed files
with
2,308 additions
and
1,874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
polaris-core/src/main/java/org/apache/polaris/core/persistence/EntityNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.polaris.core.persistence; | ||
|
||
import java.util.Optional; | ||
import org.apache.iceberg.exceptions.NoSuchNamespaceException; | ||
import org.apache.iceberg.exceptions.NoSuchTableException; | ||
import org.apache.iceberg.exceptions.NoSuchViewException; | ||
import org.apache.iceberg.exceptions.NotFoundException; | ||
import org.apache.polaris.core.entity.PolarisEntitySubType; | ||
import org.apache.polaris.core.entity.PolarisEntityType; | ||
|
||
public class EntityNotFoundException extends RuntimeException { | ||
private final PolarisEntityType entityType; | ||
private final Optional<PolarisEntitySubType> subType; | ||
private final String name; | ||
|
||
public EntityNotFoundException( | ||
PolarisEntityType entityType, Optional<PolarisEntitySubType> subType, String name) { | ||
super( | ||
subType.map(PolarisEntitySubType::readableName).orElseGet(entityType::readableName) | ||
+ " " | ||
+ name); | ||
this.entityType = entityType; | ||
this.subType = subType; | ||
this.name = name; | ||
} | ||
|
||
public EntityNotFoundException(PolarisEntityType entityType, String name) { | ||
this(entityType, Optional.empty(), name); | ||
} | ||
|
||
public RuntimeException asGenericIcebergNotFoundException() { | ||
throw new NotFoundException( | ||
"%s does not exist: %s", | ||
subType.map(PolarisEntitySubType::readableName).orElseGet(entityType::readableName), name); | ||
} | ||
|
||
public RuntimeException asSpecializedIcebergNotFoundException() { | ||
switch (entityType) { | ||
case NAMESPACE: | ||
return new NoSuchNamespaceException("Namespace does not exist: %s", name); | ||
case TABLE_LIKE: | ||
return subType | ||
.map( | ||
sub -> { | ||
switch (sub) { | ||
case TABLE: | ||
return new NoSuchTableException("Table does not exist: %s", name); | ||
case VIEW: | ||
return new NoSuchViewException("View does not exist: %s", name); | ||
default: | ||
return asGenericIcebergNotFoundException(); | ||
} | ||
}) | ||
.orElseGet(this::asGenericIcebergNotFoundException); | ||
default: | ||
return asGenericIcebergNotFoundException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.