googleapis / googleapis/google-cloud-ruby
Some pointers for Bigquery::Storage append_rows
- Dominant language
- Ruby
- Stars
- 1.4k
- Forks
- 578
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 166
Description
I've been struggling to figure out using [append_rows](https://github.com/googleapis/google-cloud-ruby/blob/f5db783627ba61e82dad2e563e8750edc0151d63/google-cloud-bigquery-storage-v1/lib/google/cloud/bigquery/storage/v1/big_query_write/client.rb#L277) in Bigquery::Storage.
The AppendRowsRequest has a proto_rows -> writer_schema -> proto_descriptor property, which I've not managed to generate properly in the ruby sdk.
I've got a protobuf descriptor for my rows, looking something like:
```ruby
Google::Protobuf::DescriptorPool.generated_pool.build do
add_file("listen.proto", :syntax => :proto2) do
add_message "MyRow" do
required :post_id, :int64, 1
required :body, :string, 2
required :timestamp, :string, 3
end
end
end
MyRow = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("MyRow").msgclass
```
and `MyRow.descriptor` returns an instance of Google::Protobuf::Descriptor.
I've been trying a lot of variations on this -
```ruby
schema = ::Google::Cloud::Bigquery::Storage::V1::ProtoSchema.new(
proto_descriptor: MyRow.descriptor
)
rows = [MyRow.new({post_id: 1, body: "aaa", timestamp: "2022-01-01").to_proto]
append_request = {
write_stream: "projects/#{project}/datasets/#{dataset}/tables/#{table}/streams/_default",
proto_rows: ::Google::Cloud::Bigquery::Storage::V1::AppendRowsRequest::ProtoData.new(
writer_schema: schema,
rows: ::Google::Cloud::Bigquery::Storage::V1::ProtoRows.new(serialized_rows: rows)
)
}
client.append_rows([append_request]).each do |response|
pp response
end
```
but that raises, eg, " Invalid type Google::Protobuf::Descriptor to assign to submessage field 'proto_descriptor'".
I confess I'm a bit fuzzy on the distinction between Descriptor and DescriptorProto. Any chance you could give a hint or two?
Contributor guide
Assessment
This issue has not been assessed yet.