mchades commented on code in PR #9737:
URL: https://github.com/apache/gravitino/pull/9737#discussion_r2703121563
##########
core/src/main/java/org/apache/gravitino/catalog/ManagedFunctionOperations.java:
##########
@@ -245,9 +260,111 @@ private void
validateDefinitionsNoArityOverlap(FunctionDefinition[] definitions)
}
}
+ private FunctionEntity applyChanges(FunctionEntity oldEntity,
FunctionChange... changes) {
+ String newComment = oldEntity.comment();
+ List<FunctionDefinition> newDefinitions =
+ new ArrayList<>(Arrays.asList(oldEntity.definitions()));
+
+ for (FunctionChange change : changes) {
+ if (change instanceof FunctionChange.UpdateComment) {
+ newComment = ((FunctionChange.UpdateComment) change).newComment();
+
+ } else if (change instanceof FunctionChange.AddDefinition) {
+ FunctionDefinition defToAdd = ((FunctionChange.AddDefinition)
change).definition();
+ validateNoArityOverlap(newDefinitions, defToAdd);
+ newDefinitions.add(defToAdd);
+
+ } else if (change instanceof FunctionChange.RemoveDefinition) {
+ FunctionParam[] paramsToRemove = ((FunctionChange.RemoveDefinition)
change).parameters();
+ validateRemoveDefinition(newDefinitions, paramsToRemove);
+ newDefinitions.removeIf(def -> parametersMatch(def.parameters(),
paramsToRemove));
+
+ } else if (change instanceof FunctionChange.AddImpl) {
+ FunctionChange.AddImpl addImpl = (FunctionChange.AddImpl) change;
+ FunctionParam[] targetParams = addImpl.parameters();
+ FunctionImpl implToAdd = addImpl.implementation();
+ newDefinitions = addImplToDefinition(newDefinitions, targetParams,
implToAdd);
Review Comment:
the validation logic is included in the method `addImplToDefinition`
--
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]