英文:
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
managedwriter
的adapt
子包包含将模式转换为描述符表示的功能。
结合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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论