-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Introduce implementation for FileType #3608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: stringify |
||
| } | ||
| } | ||
| Preconditions.checkArgument(hasPath, "FILE type group '%s' must contain required field 'path'", name); | ||
| } | ||
|
|
||
| public MapBuilder<THIS> map(Type.Repetition repetition) { | ||
| return new MapBuilder<>(self()).repetition(repetition); | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add tests for validity of size/offset fields, both their values (>= 0) and valid/invalid combinations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we validate:
offsetis present,sizemust be presentoffsetandsizemust be non-negative (note spec doesn't technically sayoffsetmust be >= 0, but I left a suggestion on that change to add it