如何使用写入存储 API 写入 BigQuery table 的 _default 流
How to write to the _default stream of a BigQuery table using the Write Storage API
我想使用 BigQuery 写入存储 API 将单行数据流式传输到 table。但是,我不想为每一行创建新的写入流。
According to the docs,每个table都有一个可以写入的默认流。 Google的解释:
Additionally, every table has a special stream named ‘_default’ to
which data can be written. This stream doesn’t need to be created
using CreateWriteStream. It is a stream that can be used
simultaneously by any number of clients. Data written to this stream
is considered committed as soon as an acknowledgement is received.
我想知道如何访问这个“_default”流并使用 Python 客户端写入它?
我尝试了以下方法:
from google.cloud import bigquery_storage_v1
write_client = bigquery_storage_v1.BigQueryWriteClient()
stream_name = "projects/{projectId}/datasets/{datasetId}/tables/{tableName}/streams/_default"
stream = write_client.get_write_stream(name=stream_name)
但是遇到错误:NotFound: 404 Requested entity was not found
编辑 2022-02-24:
事实证明,在我上面的示例中,您无法使用客户端代码获取 _default 流。但是,您可以使用名称格式 projects/{projectId}/datasets/{datasetId}/tables/{tableName}/_default
写入 _default 流
事实证明,在我上面的示例中,您无法使用客户端代码获取 _default 流。但是,您可以使用名称格式 projects/{projectId}/datasets/{datasetId}/tables/{tableName}/_default
写入 _default 流
我想使用 BigQuery 写入存储 API 将单行数据流式传输到 table。但是,我不想为每一行创建新的写入流。
According to the docs,每个table都有一个可以写入的默认流。 Google的解释:
Additionally, every table has a special stream named ‘_default’ to which data can be written. This stream doesn’t need to be created using CreateWriteStream. It is a stream that can be used simultaneously by any number of clients. Data written to this stream is considered committed as soon as an acknowledgement is received.
我想知道如何访问这个“_default”流并使用 Python 客户端写入它?
我尝试了以下方法:
from google.cloud import bigquery_storage_v1
write_client = bigquery_storage_v1.BigQueryWriteClient()
stream_name = "projects/{projectId}/datasets/{datasetId}/tables/{tableName}/streams/_default"
stream = write_client.get_write_stream(name=stream_name)
但是遇到错误:NotFound: 404 Requested entity was not found
编辑 2022-02-24:
事实证明,在我上面的示例中,您无法使用客户端代码获取 _default 流。但是,您可以使用名称格式 projects/{projectId}/datasets/{datasetId}/tables/{tableName}/_default
事实证明,在我上面的示例中,您无法使用客户端代码获取 _default 流。但是,您可以使用名称格式 projects/{projectId}/datasets/{datasetId}/tables/{tableName}/_default