【问题标题】:Bigquery Storage API gRPC http status 400 from storage.googleapis.com来自 storage.googleapis.com 的 Bigquery Storage API gRPC http 状态 400
【发布时间】:2021-02-17 18:05:42
【问题描述】:

我正在为 R 构建一个 BigQuery 存储客户端。其中一部分涉及大量调试、编译、读取代码等...

我正在尝试使用grpc_cli 复制基本的 python 示例,以了解为什么我的实现在使用 Python 时被 storage.googleapis.com 拒绝。我想我明白我要发送的内容。我认为它会产生相同的 gRPC 请求,但显然不会。

我可能仍然缺少一些东西,因为该死的 googleapis 服务器仍然返回 400。我正在使用wireshark 并嗅探数据包,但如果也不必学习如何做到这一点,那就太好了。

# 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'

【问题讨论】:

  • 在使用 GRPC_TRACE=all 激活两个跟踪之后,我想我已经将其缩小到 call.cc 中的操作序列。所以现在它可以工作了,但我不明白为什么。这很好。

标签: google-api google-bigquery grpc google-api-client google-api-python-client


【解决方案1】:

所以我想出了如何构建 BigQuery Storage R 客户端。 https://github.com/meztez/bigrquerystorage

使用 grpc_cli 访问 BigQuery Storage API 是错误的做法。

我需要使用 protoc 生成样板代码,然后从生成的代码构建客户端。

之后就是将 protobuf 字段映射到 R 输入并添加正确的凭据生成器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-04
    • 1970-01-01
    • 2012-05-30
    • 2014-01-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多