在没有协议定义的情况下使用managedwriter。

huangapple go评论77阅读模式
英文:

Using managedwriter without a protocol definition

问题

我正在尝试使用Go BigQuery Storage API Client。我已经确认可以插入大多数字段类型的数据。然而,每次插入数据时准备协议缓冲区定义并不令人愉快。Java客户端有JsonStreamWriter类,它似乎非常有用。

是否有一种像Java客户端那样,在不使用协议缓冲区定义的情况下插入数据的方法,可以在Go客户端中实现?

英文:

I am trying to use Go BigQuery Storage API Client. I checked that data can be inserted for most field types. However, preparing the protocol buffers definition isn't enjoyable every time I insert data. Java client has JsonStreamWriter class; it seems very useful.

Is there a way to insert data without a protocol buffers definition using Go client as Java client?

答案1

得分: 1

managedwriteradapt子包包含将模式转换为描述符表示的功能

结合https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson,应该可以合理地使用JSON作为中间格式。在managedwriter中还有一个集成测试展示了这一点。

如果您想分享关于特定转换需求的更多细节,请在google-cloud-go存储库上开启一个问题,并提供额外的细节。

英文:

The adapt subpackage of managedwriter includes functionality to convert a schema into a descriptor representation.

That, coupled with https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson should make it reasonable to use JSON as an intermediate format. There's an integration test in managedwriter that demonstrates this as well.

If you want to share more details about your specific conversion needs, please open an issue on the google-cloud-go repo with additional details.

huangapple
  • 本文由 发表于 2022年10月13日 01:15:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/74045712.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定