brkyvz commented on code in PR #3608:
URL: https://github.com/apache/parquet-java/pull/3608#discussion_r4426828606


##########
parquet-column/src/main/java/org/apache/parquet/schema/Types.java:
##########
@@ -821,12 +821,34 @@ public THIS addFields(Type... types) {
     @Override
     protected GroupType build(String name) {
       if (newLogicalTypeSet) {
+        if (logicalTypeAnnotation instanceof 
LogicalTypeAnnotation.FileLogicalTypeAnnotation) {
+          validateFileTypeFields(name, fields);
+        }
         return new GroupType(repetition, name, logicalTypeAnnotation, fields, 
id);
       } else {
         return new GroupType(repetition, name, getOriginalType(), fields, id);
       }
     }
 
+    private static void validateFileTypeFields(String name, List<Type> fields) 
{
+      boolean hasPath = false;
+      for (Type field : fields) {
+        String fieldName = field.getName();
+        if 
(LogicalTypeAnnotation.FileLogicalTypeAnnotation.PATH_FIELD.equals(fieldName)) {
+          Preconditions.checkArgument(
+              field.getRepetition() == Type.Repetition.REQUIRED,
+              "FILE type field 'path' must be REQUIRED in group '%s'",
+              name);
+          hasPath = true;
+        } else if 
(!LogicalTypeAnnotation.FileLogicalTypeAnnotation.OPTIONAL_FIELD_NAMES.contains(fieldName))
 {
+          throw new IllegalArgumentException(
+              "FILE type group '" + name + "' contains unrecognized field '" + 
fieldName
+                  + "'. Valid fields are: path, size, offset, etag");

Review Comment:
   Addressed: the unrecognized-field error now uses `String.join(", ", 
FIELD_NAMES)` from `FileLogicalTypeAnnotation.FIELD_NAMES`, which is also the 
set used to validate names. The diag
           nostic will therefore follow changes to the supported fields. See 
[validateFields](https://github.com/apache/parquet-java/blob/bab237a1f7b57457052f520f7cd5dae84b211e16/parquet-column
           
/src/main/java/org/apache/parquet/schema/LogicalTypeAnnotation.java#L1297).



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to