mchades commented on code in PR #14953:
URL: https://github.com/apache/gravitino/pull/14953#discussion_r4550738177


##########
core/src/main/java/org/apache/gravitino/catalog/SemanticModelValidator.java:
##########
@@ -100,22 +115,51 @@ 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);
+      validateUniqueName(field.name(), namePath, "field", uniqueNames);
+      fieldNames.add(normalizeFieldName(field.name()));
+    }
+    return fieldNames;
+  }

Review Comment:
   Verified against the upstream Ossie validator (`validation/validate.py` on 
main): `dataset_field_names()` case-folds field names for reference resolution 
while `validate_unique_names()` compares raw spellings, so `id`/`ID` fields 
produce the same ambiguity upstream. This PR intentionally mirrors that 
contract — tightening uniqueness unilaterally would reject documents the 
reference validator accepts. Filed apache/ossie#721 to resolve the ambiguity at 
the spec/validator level.



##########
web-v2/web/src/lib/utils/semanticModel.js:
##########
@@ -38,6 +38,24 @@ export const semanticDataTypes = [
 
 const isNonBlankString = value => typeof value === 'string' && value.trim() 
!== ''
 
+const normalizeFieldName = name => name.toLowerCase()
+
+const declaredFieldNames = dataset =>
+  new Set(
+    (Array.isArray(dataset?.fields) ? dataset.fields : [])
+      .map(field => field?.name)
+      .filter(isNonBlankString)
+      .map(normalizeFieldName)
+  )
+

Review Comment:
   Same conclusion as the server-side thread: the web validator mirrors the 
upstream contract (case-insensitive resolution, case-sensitive uniqueness), 
which carries the same edge case. Tracking the ambiguity upstream in 
apache/ossie#721 rather than diverging here.



##########
core/src/main/java/org/apache/gravitino/catalog/SemanticModelValidator.java:
##########
@@ -100,22 +115,51 @@ 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);
+      validateUniqueName(field.name(), namePath, "field", uniqueNames);
+      fieldNames.add(normalizeFieldName(field.name()));

Review Comment:
   Checked the upstream validator: reference resolution case-folds field names 
while uniqueness compares raw spellings, so this ambiguity exists upstream as 
well. We mirror that contract deliberately; filed apache/ossie#721 to settle 
the case rules upstream.



-- 
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]

Reply via email to