Skip to content

Commit bc88aa5

Browse files
feat: add support for proto3 optional tag (#2295)
1 parent fd8aaae commit bc88aa5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ProtoSchemaConverter.java

+11
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ private static ProtoSchema convertInternal(
102102
enumTypes.add(enumFullName);
103103
}
104104
}
105+
// The protobuf payload will be decoded as proto2 on the server side. The schema is also
106+
// specified as proto2. Hence we must clear proto3-only features. This works since proto2 and
107+
// proto3 are binary-compatible.
108+
if (resultField.hasProto3Optional()) {
109+
// Clear proto3-only features
110+
resultField.clearProto3Optional();
111+
}
112+
if (resultField.hasOneofIndex()) {
113+
// Clear proto3-only features
114+
resultField.clearOneofIndex();
115+
}
105116
resultProto.addField(resultField);
106117
}
107118
structTypes.add(protoFullName);

0 commit comments

Comments
 (0)