mchades commented on code in PR #14953:
URL: https://github.com/apache/gravitino/pull/14953#discussion_r4560275839
##########
core/src/main/java/org/apache/gravitino/catalog/SemanticModelValidator.java:
##########
@@ -100,22 +116,53 @@ private static void validateSource(NameIdentifier source,
String path) {
}
}
- private static void validateFields(@Nullable Field[] fields, String path) {
+ private static Set<String> validateFields(@Nullable Field[] fields, String
path) {
+ Set<String> fieldNames = new HashSet<>();
if (fields == null) {
- return;
+ return fieldNames;
}
- Map<String, String> fieldNames = new HashMap<>();
+ Map<String, String> uniqueNames = new HashMap<>();
for (int index = 0; index < fields.length; index++) {
String fieldPath = path + "[" + index + "]";
Field field = fields[index];
String namePath = fieldPath + ".name";
- validateUniqueName(field.name(), namePath, "field", fieldNames);
+ // Key and relationship references resolve field names
case-insensitively, so two
+ // declared names equal ignoring case would make every reference to them
ambiguous.
+ validateUniqueName(normalizeFieldName(field.name()), namePath, "field",
uniqueNames);
Review Comment:
Not spec-mandated — intentionally stricter than upstream. `validate.py`'s
`find_duplicates` compares raw strings, so `Id`/`ID` also passes there while
references casefold onto a single entry; that ambiguity is tracked in
apache/ossie#721. Rejecting the ambiguous declaration is the deliberate choice
from the earlier thread.
On persisted models: stored definitions are never re-validated — load,
export, and metadata-only alters (rename/comment/property) don't run the
definition validator at all; only a newly submitted `replaceDefinition` is
checked. So an already-stored `Id`/`ID` model keeps working, and is only
affected when its owner writes a new definition still containing the
conflicting names — which is the ambiguous declaration being rejected. And
since Semantic Models are unreleased (first shipping in 2.0.0), no released
deployment can hold such a model anyway.
--
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]