This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-java.git
The following commit(s) were added to refs/heads/master by this push:
new a6bad6a8e GH-3175: support protobuf library version 4 (#3352)
a6bad6a8e is described below
commit a6bad6a8e838cce21a225c9a4ceaec6c8b3d76e0
Author: Uwe Maurer <[email protected]>
AuthorDate: Thu Nov 20 00:01:05 2025 +0100
GH-3175: support protobuf library version 4 (#3352)
* support protobuf library version 4
The getSyntax method on messageDescriptor.getFile() got removed
in protobuf version 4.
This change gets the syntax information directly from the proto, this
works in protobuf v3 and v4.
fixes https://github.com/apache/parquet-java/issues/3175
see also https://github.com/apache/parquet-java/pull/3182
* fix formatting
---
.../main/java/org/apache/parquet/proto/ProtoWriteSupport.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git
a/parquet-protobuf/src/main/java/org/apache/parquet/proto/ProtoWriteSupport.java
b/parquet-protobuf/src/main/java/org/apache/parquet/proto/ProtoWriteSupport.java
index 637f6fda9..389e84284 100644
---
a/parquet-protobuf/src/main/java/org/apache/parquet/proto/ProtoWriteSupport.java
+++
b/parquet-protobuf/src/main/java/org/apache/parquet/proto/ProtoWriteSupport.java
@@ -445,10 +445,13 @@ public class ProtoWriteSupport<T extends
MessageOrBuilder> extends WriteSupport<
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 +467,7 @@ public class ProtoWriteSupport<T extends MessageOrBuilder>
extends WriteSupport<
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();