Unclear documentation for generating protobuf schema - C#

400 views
Skip to first unread message

Ben Guest

unread,
Jul 1, 2022, 2:09:08 AM7/1/22
to Protocol Buffers
I'm trying to using the BigQuery Storage V1 Write client to update bigquery in a C# app.
I'm following the example in the dotnet reference but it doesn't contain a complete setup.
I've written a sample proto message that I believe follows the requirements laid out in the documentation, but I get an error message when attempting to append a row.
This leads me to believe that I'm not creating my ProtoDescriptor correctly, and I'm unable to find the correct documentation on how to map a type to a ProtoDescriptor?

The documentation for the proto schema states that I should be able to include the known types.

My error message is: 
Grpc.Core.RpcException : Status(StatusCode="InvalidArgument", Detail="Invalid proto schema: BqMessage.proto: RequestSummaryTableMessage.request_id: ".google.protobuf.StringValue" is not defined
proto spec:
syntax="proto3"
import "google/protobuf/wrapper.proto"
message TableUpdate {
 google.protobuf.StringValue request_id = 1;
}
C# code:
var protoRows = new AppendRowsRequest.Types.ProtoData();
var mappedMessage =<irrelevant mapper to proto model>
// Initialize a request
var row = new ProtoRows
{
SerializedRows = { mappedMessage.ToByteString() },
};

protoRows.Rows = row;
protoRows.WriterSchema = new ProtoSchema
{
ProtoDescriptor = TableUpdateMessage.Descriptor.ToProto(),
};
AppendRowsRequest request = new ()
{
WriteStreamAsWriteStreamName = WriteStreamName.FromProjectDatasetTableStream("[PROJECT]", "[DATASET]", "[TABLE_NAME]", "_default"),
Offset = 0L,
ProtoRows = protoRows,
TraceId = string.Empty,
};

David Castro

unread,
Jul 1, 2022, 9:01:31 AM7/1/22
to Protocol Buffers
I'm new to protobufs, so I might be missing other issues with your code, but try replacing:

import "google/protobuf/wrapper.proto" 

with:

import "google/protobuf/wrappers.proto" 

(with the "s"). 

jons...@google.com

unread,
Jul 1, 2022, 9:19:50 AM7/1/22
to Protocol Buffers
Please could you file an issue on https://github.com/googleapis/google-cloud-dotnet? This feels more like an "API and .NET client library" issue than a "core protobuf issue".

Basically include the same information that you have here, and we can go from there. Admittedly we (the maintainers of that repo) don't have experience with all of the APIs we maintain client libraries for, but hopefully we'll be able to dig into it.

Jon

Reply all
Reply to author
Forward
0 new messages