ccciudatu commented on a change in pull request #13572:
URL: https://github.com/apache/beam/pull/13572#discussion_r548434293



##########
File path: 
sdks/java/io/thrift/src/main/java/org/apache/beam/sdk/io/thrift/ThriftSchema.java
##########
@@ -183,7 +188,12 @@ private Schema schemaFor(Class<?> targetClass) {
   private Schema.Field beamField(FieldMetaData fieldDescriptor) {
     try {
       final FieldType type = beamType(fieldDescriptor.valueMetaData);
-      return Schema.Field.nullable(fieldDescriptor.fieldName, type);
+      switch (fieldDescriptor.requirementType) {
+        case TFieldRequirementType.REQUIRED:
+          return Schema.Field.of(fieldDescriptor.fieldName, type);
+        default:
+          return Schema.Field.nullable(fieldDescriptor.fieldName, type);
+      }

Review comment:
       Fields used to always be nullable for thrift schemas and the table 
integration test requires non-nullable fields. So I just added what was 
actually missing, i.e. marking `required` as non-nullable in beam. `default` is 
still nullable, the same as `optional`, for safety reasons -- as it's defined 
as "opt-in, req-out".




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to