uwemaurer commented on issue #3175:
URL: https://github.com/apache/parquet-java/issues/3175#issuecomment-3400936292

   We were able to upgrade to protobuf `4.32.1` and only had to replace 
`ProtoWriteSupport.java` with a patched version, using the patch below:
   
   ```
   @@ -445,10 +445,14 @@
    
        private void writeAllFields(MessageOrBuilder pb) {
          Descriptor messageDescriptor = pb.getDescriptorForType();
   -      Descriptors.FileDescriptor.Syntax syntax =
   -          messageDescriptor.getFile().getSyntax();
   +      String syntax =
   +          messageDescriptor.getFile().toProto().getSyntax();
   +      if ("editions".equals(syntax)) {
   +          throw new UnsupportedOperationException("protocol buffers 
'editions' not supported");
   +      }
   +      boolean isProto2 = !"proto3".equals(syntax);
    
   -      if (Descriptors.FileDescriptor.Syntax.PROTO2.equals(syntax)) {
   +      if (isProto2) {
            // Returns changed fields with values. Map is ordered by id.
            Map<FieldDescriptor, Object> changedPbFields = pb.getAllFields();
    
   @@ -464,7 +468,7 @@
              int fieldIndex = fieldDescriptor.getIndex();
              fieldWriters[fieldIndex].writeField(entry.getValue());
            }
   -      } else if (Descriptors.FileDescriptor.Syntax.PROTO3.equals(syntax)) {
   +      } else {
            List<FieldDescriptor> fieldDescriptors = 
messageDescriptor.getFields();
            for (FieldDescriptor fieldDescriptor : fieldDescriptors) {
              FieldDescriptor.Type type = fieldDescriptor.getType();
   @@ -797,4 +801,3 @@
        throw new InvalidRecordException(exceptionMsg);
      }
    }
   ```
   
   This code should actually also work with the protobuf 3 library. The problem 
war that in protobuf 4 the `getFile().getSytax()` method is not there anymore, 
but `getFile().toProto().getSyntax()` works (returns a String instead of enum)


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