From 29846003d4bebb1a07ac11cac462ae65cb0bc59c Mon Sep 17 00:00:00 2001 From: shollyman Date: Thu, 19 May 2022 14:03:20 -0700 Subject: [PATCH] feat(bigquery/storage/managedwriter/adapt): support proto3 presence (#6021) This PR changes the normalizer to clear the proto3 optional presence field in the FieldDescriptorProto. The backend can treat this case as an instance of proto2 optional. More background information: https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md --- .../managedwriter/adapt/protoconversion.go | 5 + .../adapt/protoconversion_test.go | 23 ++ .../testdata/messages_proto3.pb.go | 206 ++++++++++++------ .../testdata/messages_proto3.proto | 6 + 4 files changed, 173 insertions(+), 67 deletions(-) diff --git a/bigquery/storage/managedwriter/adapt/protoconversion.go b/bigquery/storage/managedwriter/adapt/protoconversion.go index a27b54cc06e5..d3a0d239db88 100644 --- a/bigquery/storage/managedwriter/adapt/protoconversion.go +++ b/bigquery/storage/managedwriter/adapt/protoconversion.go @@ -311,6 +311,11 @@ func normalizeDescriptorInternal(in protoreflect.MessageDescriptor, visitedTypes for i := 0; i < in.Fields().Len(); i++ { inField := in.Fields().Get(i) resultFDP := protodesc.ToFieldDescriptorProto(inField) + // Clear proto3 optional annotation, as the backend converter can + // treat this as a proto2 optional. + if resultFDP.Proto3Optional != nil { + resultFDP.Proto3Optional = nil + } if resultFDP.OneofIndex != nil { resultFDP.OneofIndex = nil } diff --git a/bigquery/storage/managedwriter/adapt/protoconversion_test.go b/bigquery/storage/managedwriter/adapt/protoconversion_test.go index 268f3ba30a69..1e5c3d647fa0 100644 --- a/bigquery/storage/managedwriter/adapt/protoconversion_test.go +++ b/bigquery/storage/managedwriter/adapt/protoconversion_test.go @@ -621,6 +621,29 @@ func TestNormalizeDescriptor(t *testing.T) { }, }, }, + { + description: "WithProto3Optional", + in: (&testdata.SimpleMessageProto3WithOptional{}).ProtoReflect().Descriptor(), + want: &descriptorpb.DescriptorProto{ + Name: proto.String("testdata_SimpleMessageProto3WithOptional"), + Field: []*descriptorpb.FieldDescriptorProto{ + { + Name: proto.String("name"), + JsonName: proto.String("name"), + Number: proto.Int32(1), + Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), + }, + { + Name: proto.String("value"), + JsonName: proto.String("value"), + Number: proto.Int32(2), + Type: descriptorpb.FieldDescriptorProto_TYPE_INT64.Enum(), + Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), + }, + }, + }, + }, { description: "WithExternalEnum", in: (&testdata.ExternalEnumMessage{}).ProtoReflect().Descriptor(), diff --git a/bigquery/storage/managedwriter/testdata/messages_proto3.pb.go b/bigquery/storage/managedwriter/testdata/messages_proto3.pb.go index 1422ac357d50..e675992302d8 100644 --- a/bigquery/storage/managedwriter/testdata/messages_proto3.pb.go +++ b/bigquery/storage/managedwriter/testdata/messages_proto3.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0 -// protoc v3.10.1 +// protoc-gen-go v1.28.0 +// protoc v3.17.3 // source: messages_proto3.proto package testdata @@ -24,10 +24,9 @@ import ( reflect "reflect" sync "sync" - proto "github.com/golang/protobuf/proto" - wrappers "github.com/golang/protobuf/ptypes/wrappers" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" ) const ( @@ -37,10 +36,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - // SimpleMessageProto3 represents a simple message that transmits a string and int64 value. type SimpleMessageProto3 struct { state protoimpl.MessageState @@ -50,7 +45,7 @@ type SimpleMessageProto3 struct { // name is a simple scalar string. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // value is a simple int64 value. - Value *wrappers.Int64Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Value *wrapperspb.Int64Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` } func (x *SimpleMessageProto3) Reset() { @@ -92,7 +87,7 @@ func (x *SimpleMessageProto3) GetName() string { return "" } -func (x *SimpleMessageProto3) GetValue() *wrappers.Int64Value { +func (x *SimpleMessageProto3) GetValue() *wrapperspb.Int64Value { if x != nil { return x.Value } @@ -104,11 +99,11 @@ type GithubArchiveEntityProto3 struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id *wrappers.Int64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Login *wrappers.StringValue `protobuf:"bytes,2,opt,name=login,proto3" json:"login,omitempty"` - GravatarId *wrappers.StringValue `protobuf:"bytes,3,opt,name=gravatar_id,json=gravatarId,proto3" json:"gravatar_id,omitempty"` - AvatarUrl *wrappers.StringValue `protobuf:"bytes,4,opt,name=avatar_url,json=avatarUrl,proto3" json:"avatar_url,omitempty"` - Url *wrappers.StringValue `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"` + Id *wrapperspb.Int64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Login *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=login,proto3" json:"login,omitempty"` + GravatarId *wrapperspb.StringValue `protobuf:"bytes,3,opt,name=gravatar_id,json=gravatarId,proto3" json:"gravatar_id,omitempty"` + AvatarUrl *wrapperspb.StringValue `protobuf:"bytes,4,opt,name=avatar_url,json=avatarUrl,proto3" json:"avatar_url,omitempty"` + Url *wrapperspb.StringValue `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"` } func (x *GithubArchiveEntityProto3) Reset() { @@ -143,35 +138,35 @@ func (*GithubArchiveEntityProto3) Descriptor() ([]byte, []int) { return file_messages_proto3_proto_rawDescGZIP(), []int{1} } -func (x *GithubArchiveEntityProto3) GetId() *wrappers.Int64Value { +func (x *GithubArchiveEntityProto3) GetId() *wrapperspb.Int64Value { if x != nil { return x.Id } return nil } -func (x *GithubArchiveEntityProto3) GetLogin() *wrappers.StringValue { +func (x *GithubArchiveEntityProto3) GetLogin() *wrapperspb.StringValue { if x != nil { return x.Login } return nil } -func (x *GithubArchiveEntityProto3) GetGravatarId() *wrappers.StringValue { +func (x *GithubArchiveEntityProto3) GetGravatarId() *wrapperspb.StringValue { if x != nil { return x.GravatarId } return nil } -func (x *GithubArchiveEntityProto3) GetAvatarUrl() *wrappers.StringValue { +func (x *GithubArchiveEntityProto3) GetAvatarUrl() *wrapperspb.StringValue { if x != nil { return x.AvatarUrl } return nil } -func (x *GithubArchiveEntityProto3) GetUrl() *wrappers.StringValue { +func (x *GithubArchiveEntityProto3) GetUrl() *wrapperspb.StringValue { if x != nil { return x.Url } @@ -183,9 +178,9 @@ type GithubArchiveRepoProto3 struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id *wrappers.Int64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name *wrappers.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Url *wrappers.StringValue `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` + Id *wrapperspb.Int64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Url *wrapperspb.StringValue `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` } func (x *GithubArchiveRepoProto3) Reset() { @@ -220,21 +215,21 @@ func (*GithubArchiveRepoProto3) Descriptor() ([]byte, []int) { return file_messages_proto3_proto_rawDescGZIP(), []int{2} } -func (x *GithubArchiveRepoProto3) GetId() *wrappers.Int64Value { +func (x *GithubArchiveRepoProto3) GetId() *wrapperspb.Int64Value { if x != nil { return x.Id } return nil } -func (x *GithubArchiveRepoProto3) GetName() *wrappers.StringValue { +func (x *GithubArchiveRepoProto3) GetName() *wrapperspb.StringValue { if x != nil { return x.Name } return nil } -func (x *GithubArchiveRepoProto3) GetUrl() *wrappers.StringValue { +func (x *GithubArchiveRepoProto3) GetUrl() *wrapperspb.StringValue { if x != nil { return x.Url } @@ -247,15 +242,15 @@ type GithubArchiveMessageProto3 struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Type *wrappers.StringValue `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Public *wrappers.BoolValue `protobuf:"bytes,2,opt,name=public,proto3" json:"public,omitempty"` - Payload *wrappers.StringValue `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` + Type *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Public *wrapperspb.BoolValue `protobuf:"bytes,2,opt,name=public,proto3" json:"public,omitempty"` + Payload *wrapperspb.StringValue `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` Repo *GithubArchiveRepoProto3 `protobuf:"bytes,4,opt,name=repo,proto3" json:"repo,omitempty"` Actor *GithubArchiveEntityProto3 `protobuf:"bytes,5,opt,name=actor,proto3" json:"actor,omitempty"` Org *GithubArchiveEntityProto3 `protobuf:"bytes,6,opt,name=org,proto3" json:"org,omitempty"` - CreatedAt *wrappers.Int64Value `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - Id *wrappers.StringValue `protobuf:"bytes,8,opt,name=id,proto3" json:"id,omitempty"` - Other *wrappers.StringValue `protobuf:"bytes,9,opt,name=other,proto3" json:"other,omitempty"` + CreatedAt *wrapperspb.Int64Value `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + Id *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=id,proto3" json:"id,omitempty"` + Other *wrapperspb.StringValue `protobuf:"bytes,9,opt,name=other,proto3" json:"other,omitempty"` } func (x *GithubArchiveMessageProto3) Reset() { @@ -290,21 +285,21 @@ func (*GithubArchiveMessageProto3) Descriptor() ([]byte, []int) { return file_messages_proto3_proto_rawDescGZIP(), []int{3} } -func (x *GithubArchiveMessageProto3) GetType() *wrappers.StringValue { +func (x *GithubArchiveMessageProto3) GetType() *wrapperspb.StringValue { if x != nil { return x.Type } return nil } -func (x *GithubArchiveMessageProto3) GetPublic() *wrappers.BoolValue { +func (x *GithubArchiveMessageProto3) GetPublic() *wrapperspb.BoolValue { if x != nil { return x.Public } return nil } -func (x *GithubArchiveMessageProto3) GetPayload() *wrappers.StringValue { +func (x *GithubArchiveMessageProto3) GetPayload() *wrapperspb.StringValue { if x != nil { return x.Payload } @@ -332,27 +327,84 @@ func (x *GithubArchiveMessageProto3) GetOrg() *GithubArchiveEntityProto3 { return nil } -func (x *GithubArchiveMessageProto3) GetCreatedAt() *wrappers.Int64Value { +func (x *GithubArchiveMessageProto3) GetCreatedAt() *wrapperspb.Int64Value { if x != nil { return x.CreatedAt } return nil } -func (x *GithubArchiveMessageProto3) GetId() *wrappers.StringValue { +func (x *GithubArchiveMessageProto3) GetId() *wrapperspb.StringValue { if x != nil { return x.Id } return nil } -func (x *GithubArchiveMessageProto3) GetOther() *wrappers.StringValue { +func (x *GithubArchiveMessageProto3) GetOther() *wrapperspb.StringValue { if x != nil { return x.Other } return nil } +type SimpleMessageProto3WithOptional struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // name is a simple scalar string. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // value is an int64 value with optional presence. + Value *int64 `protobuf:"varint,2,opt,name=value,proto3,oneof" json:"value,omitempty"` +} + +func (x *SimpleMessageProto3WithOptional) Reset() { + *x = SimpleMessageProto3WithOptional{} + if protoimpl.UnsafeEnabled { + mi := &file_messages_proto3_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SimpleMessageProto3WithOptional) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SimpleMessageProto3WithOptional) ProtoMessage() {} + +func (x *SimpleMessageProto3WithOptional) ProtoReflect() protoreflect.Message { + mi := &file_messages_proto3_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SimpleMessageProto3WithOptional.ProtoReflect.Descriptor instead. +func (*SimpleMessageProto3WithOptional) Descriptor() ([]byte, []int) { + return file_messages_proto3_proto_rawDescGZIP(), []int{4} +} + +func (x *SimpleMessageProto3WithOptional) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SimpleMessageProto3WithOptional) GetValue() int64 { + if x != nil && x.Value != nil { + return *x.Value + } + return 0 +} + var File_messages_proto3_proto protoreflect.FileDescriptor var file_messages_proto3_proto_rawDesc = []byte{ @@ -427,11 +479,17 @@ var file_messages_proto3_proto_rawDesc = []byte{ 0x65, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x05, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x52, 0x05, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x42, 0x3d, 0x5a, 0x3b, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x2f, 0x62, 0x69, 0x67, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72, 0x2f, - 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x65, 0x52, 0x05, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x22, 0x5a, 0x0a, 0x1f, 0x53, 0x69, 0x6d, + 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x57, 0x69, 0x74, 0x68, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x19, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x48, + 0x00, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x67, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x64, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74, + 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -446,35 +504,36 @@ func file_messages_proto3_proto_rawDescGZIP() []byte { return file_messages_proto3_proto_rawDescData } -var file_messages_proto3_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_messages_proto3_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_messages_proto3_proto_goTypes = []interface{}{ - (*SimpleMessageProto3)(nil), // 0: testdata.SimpleMessageProto3 - (*GithubArchiveEntityProto3)(nil), // 1: testdata.GithubArchiveEntityProto3 - (*GithubArchiveRepoProto3)(nil), // 2: testdata.GithubArchiveRepoProto3 - (*GithubArchiveMessageProto3)(nil), // 3: testdata.GithubArchiveMessageProto3 - (*wrappers.Int64Value)(nil), // 4: google.protobuf.Int64Value - (*wrappers.StringValue)(nil), // 5: google.protobuf.StringValue - (*wrappers.BoolValue)(nil), // 6: google.protobuf.BoolValue + (*SimpleMessageProto3)(nil), // 0: testdata.SimpleMessageProto3 + (*GithubArchiveEntityProto3)(nil), // 1: testdata.GithubArchiveEntityProto3 + (*GithubArchiveRepoProto3)(nil), // 2: testdata.GithubArchiveRepoProto3 + (*GithubArchiveMessageProto3)(nil), // 3: testdata.GithubArchiveMessageProto3 + (*SimpleMessageProto3WithOptional)(nil), // 4: testdata.SimpleMessageProto3WithOptional + (*wrapperspb.Int64Value)(nil), // 5: google.protobuf.Int64Value + (*wrapperspb.StringValue)(nil), // 6: google.protobuf.StringValue + (*wrapperspb.BoolValue)(nil), // 7: google.protobuf.BoolValue } var file_messages_proto3_proto_depIdxs = []int32{ - 4, // 0: testdata.SimpleMessageProto3.value:type_name -> google.protobuf.Int64Value - 4, // 1: testdata.GithubArchiveEntityProto3.id:type_name -> google.protobuf.Int64Value - 5, // 2: testdata.GithubArchiveEntityProto3.login:type_name -> google.protobuf.StringValue - 5, // 3: testdata.GithubArchiveEntityProto3.gravatar_id:type_name -> google.protobuf.StringValue - 5, // 4: testdata.GithubArchiveEntityProto3.avatar_url:type_name -> google.protobuf.StringValue - 5, // 5: testdata.GithubArchiveEntityProto3.url:type_name -> google.protobuf.StringValue - 4, // 6: testdata.GithubArchiveRepoProto3.id:type_name -> google.protobuf.Int64Value - 5, // 7: testdata.GithubArchiveRepoProto3.name:type_name -> google.protobuf.StringValue - 5, // 8: testdata.GithubArchiveRepoProto3.url:type_name -> google.protobuf.StringValue - 5, // 9: testdata.GithubArchiveMessageProto3.type:type_name -> google.protobuf.StringValue - 6, // 10: testdata.GithubArchiveMessageProto3.public:type_name -> google.protobuf.BoolValue - 5, // 11: testdata.GithubArchiveMessageProto3.payload:type_name -> google.protobuf.StringValue + 5, // 0: testdata.SimpleMessageProto3.value:type_name -> google.protobuf.Int64Value + 5, // 1: testdata.GithubArchiveEntityProto3.id:type_name -> google.protobuf.Int64Value + 6, // 2: testdata.GithubArchiveEntityProto3.login:type_name -> google.protobuf.StringValue + 6, // 3: testdata.GithubArchiveEntityProto3.gravatar_id:type_name -> google.protobuf.StringValue + 6, // 4: testdata.GithubArchiveEntityProto3.avatar_url:type_name -> google.protobuf.StringValue + 6, // 5: testdata.GithubArchiveEntityProto3.url:type_name -> google.protobuf.StringValue + 5, // 6: testdata.GithubArchiveRepoProto3.id:type_name -> google.protobuf.Int64Value + 6, // 7: testdata.GithubArchiveRepoProto3.name:type_name -> google.protobuf.StringValue + 6, // 8: testdata.GithubArchiveRepoProto3.url:type_name -> google.protobuf.StringValue + 6, // 9: testdata.GithubArchiveMessageProto3.type:type_name -> google.protobuf.StringValue + 7, // 10: testdata.GithubArchiveMessageProto3.public:type_name -> google.protobuf.BoolValue + 6, // 11: testdata.GithubArchiveMessageProto3.payload:type_name -> google.protobuf.StringValue 2, // 12: testdata.GithubArchiveMessageProto3.repo:type_name -> testdata.GithubArchiveRepoProto3 1, // 13: testdata.GithubArchiveMessageProto3.actor:type_name -> testdata.GithubArchiveEntityProto3 1, // 14: testdata.GithubArchiveMessageProto3.org:type_name -> testdata.GithubArchiveEntityProto3 - 4, // 15: testdata.GithubArchiveMessageProto3.created_at:type_name -> google.protobuf.Int64Value - 5, // 16: testdata.GithubArchiveMessageProto3.id:type_name -> google.protobuf.StringValue - 5, // 17: testdata.GithubArchiveMessageProto3.other:type_name -> google.protobuf.StringValue + 5, // 15: testdata.GithubArchiveMessageProto3.created_at:type_name -> google.protobuf.Int64Value + 6, // 16: testdata.GithubArchiveMessageProto3.id:type_name -> google.protobuf.StringValue + 6, // 17: testdata.GithubArchiveMessageProto3.other:type_name -> google.protobuf.StringValue 18, // [18:18] is the sub-list for method output_type 18, // [18:18] is the sub-list for method input_type 18, // [18:18] is the sub-list for extension type_name @@ -536,14 +595,27 @@ func file_messages_proto3_proto_init() { return nil } } + file_messages_proto3_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SimpleMessageProto3WithOptional); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } + file_messages_proto3_proto_msgTypes[4].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_messages_proto3_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/bigquery/storage/managedwriter/testdata/messages_proto3.proto b/bigquery/storage/managedwriter/testdata/messages_proto3.proto index 2d298362449d..9760d0515cdb 100644 --- a/bigquery/storage/managedwriter/testdata/messages_proto3.proto +++ b/bigquery/storage/managedwriter/testdata/messages_proto3.proto @@ -54,3 +54,9 @@ message GithubArchiveMessageProto3 { google.protobuf.StringValue other = 9; } +message SimpleMessageProto3WithOptional { + // name is a simple scalar string. + string name = 1; + // value is an int64 value with optional presence. + optional int64 value = 2; +} \ No newline at end of file