mchades commented on code in PR #14953:
URL: https://github.com/apache/gravitino/pull/14953#discussion_r4560287709
##########
core/src/main/java/org/apache/gravitino/catalog/ManagedSemanticModelOperations.java:
##########
@@ -243,9 +243,17 @@ public SemanticModel alterSemanticModel(
oldEntity -> {
SemanticModelEntity candidate = applyChanges(oldEntity,
sourceUpdate, changes);
if (validateForWrite) {
- writeValidator.accept(
- NameIdentifier.of(candidate.namespace(), candidate.name()),
- candidate.definition());
+ NameIdentifier candidateIdent =
+ NameIdentifier.of(candidate.namespace(), candidate.name());
+ // Every replacement is validated, even when a later change
replaces the
+ // definition again before the update is persisted.
+ for (SemanticModelChange change : changes) {
+ if (change instanceof SemanticModelChange.ReplaceDefinition) {
+ writeValidator.accept(
+ candidateIdent,
Review Comment:
Under the current change set the candidate is always already validated:
`applyChanges` starts from the stored definition and only `ReplaceDefinition`
can overwrite it, so whenever `validateForWrite` holds,
`candidate.definition()` is exactly the last replacement's definition — the
same object the loop just checked. A future change type that could mutate the
definition is rejected today (`requiresWriteValidation` throws on unknown
change types), so the gap can't open silently; and the merged result still goes
through `sourceUpdate.validate(candidate.definition())`. Given that, the extra
call would be a guaranteed duplicate, so I'd prefer to keep validation
per-replacement.
--
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]