如何解决storage.googleapis.com的Bigquery Storage API gRPC HTTP状态400
我正在为R构建BigQuery Storage Client。其中一部分涉及大量调试,编译,读取代码等...
我正尝试使用grpc_cli
复制基本的python示例,以了解为什么我的实现在通过Python时会被storage.googleapis.com拒绝。我想我知道我要发送的内容。我认为它会产生相同的gRPC请求,但显然不会。
由于该死的googleapis服务器仍返回400,我可能仍然缺少一些东西。我要进行有线通讯和嗅探数据包,但是如果不必学习如何做,那也很好。 / p>
# export GRPC_TRACE=all
# export GRPC_VERBOSITY=DEBUG
unset GRPC_TRACE
export GRPC_VERBOSITY=ERROR
export GOOGLE_APPLICATION_CREDENTIALS="bq-storage-dev.json"
grpc_cli call bigquerystorage.googleapis.com:443 google.cloud.bigquery.storage.v1.BigQueryRead/CreateReadSession --protofiles google/cloud/bigquery/storage/v1/storage.proto --proto_path ~/bigrquerystorage/inst/proto --channel_creds_type=gdc --json_output --binary_input --infile=~/request.bin --noremotedb --metadata=x-goog-request-params:read_session.table=projects/bigquery-public-data/datasets/usa_names/tables/usa_1910_current:x-goog-api-client:bigrquerystorage%20gl-r/4.0.3x86_64-pc-linux-gnu%20grpc/13.0.0_geeky%20gccl/0.2.0%20gargle/0.5.0
request.bin是会话对象的二进制内容
> serialize(session,NULL)
[1] 0a 22 70 72 6f 6a 65 63 74 73 2f 6c 61 62 6f 2d 62 72 75 6e 6f 74 72 65 6d 62 6c 61
[29] 79 2d 32 35 33 33 31 37 12 71 18 01 32 48 70 72 6f 6a 65 63 74 73 2f 62 69 67 71 75
[57] 65 72 79 2d 70 75 62 6c 69 63 2d 64 61 74 61 2f 64 61 74 61 73 65 74 73 2f 75 73 61
[85] 5f 6e 61 6d 65 73 2f 74 61 62 6c 65 73 2f 75 73 61 5f 31 39 31 30 5f 63 75 72 72 65
[113] 6e 74 42 23 0a 04 6e 61 6d 65 0a 06 6e 75 6d 62 65 72 0a 05 73 74 61 74 65 12 0c 73
[141] 74 61 74 65 20 3d 20 22 57 41 22 18 01
> rawToChar(serialize(session,NULL))
[1] "\n\"projects/labo-brunotremblay-253317\022q\030\0012Hprojects/bigquery-public-data/datasets/usa_names/tables/usa_1910_currentB#\n\004name\n\006number\n\005state\022\fstate = \"WA\"\030\001"
非常感谢您的帮助
编辑: 相当于Python的request.bin,效果很好。
>>> from google.cloud.bigquery_storage_v1.types import storage
>>> request_serializer=storage.CreateReadSessionRequest.serialize
>>> request = storage.CreateReadSessionRequest(None)
>>> request.parent = parent
>>> request.read_session = requested_session
>>> request.max_stream_count = 1
>>> request_serializer(request)
b'\n"projects/labo-brunotremblay-253317\x12q\x18\x012Hprojects/bigquery-public-data/datasets/usa_names/tables/usa_1910_currentB#\n\x04name\n\x06number\n\x05state\x12\x0cstate = "WA"\x18\x01'
解决方法
因此,我弄清楚了如何构建BigQuery Storage R Client。 https://github.com/meztez/bigrquerystorage
使用grpc_cli访问BigQuery Storage API是错误的方法。
我需要使用protoc生成样板代码,然后从生成的代码构建客户端。
此后,只需要将protobuf字段映射到R输入并添加正确的凭据构建器即可。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。