尝试使用从 Google App Engine 到 BigQuery 的 insertAll 时出现 HTTP 501 错误

HTTP 501 error when trying to use insertAll from Google App Engine to BigQuery

已解决: 正如 Felipe 在评论中建议的那样,我使用 EU 作为数据位置。流式传输在 BigQuery 的欧盟数据中心不可用,因此我不得不将我的数据迁移到美国数据中心,之后一切都按预期进行。

我的问题: 我正在尝试使用 Google App Engine(python 版本)将数据推送到 BigQuery。在实际插入发生之前,一切似乎都很好,之后我收到 HTTP 501 错误。 Google 的错误代码 sheet 让我参考 "Contact support"。

错误响应:
HttpError: https://www.googleapis.com/bigquery/v2/projects/[PROJECT]/datasets/[DATASET]/tables/[TABLE]/insertAll?alt=json 返回 "Not Implemented: Streaming ingestion is disabled for the destination dataset.">

实际使用的代码:

class MainHandler(webapp2.RequestHandler):
    def get(self):
        data = json.loads(self.request.get('data'))
        body = {
            'insertId': str(uuid4()),
            'rows':[
                {'json': data}
            ]
        }

        credentials = appengine.AppAssertionCredentials(scope=_SCOPE)
        http = credentials.authorize(httplib2.Http())
        bigquery = discovery.build('bigquery', 'v2', http=http)
        response = bigquery.tabledata().insertAll(
            projectId=PROJECT_ID,
            datasetId=DATASET_ID,
            tableId=TABLE_ID,
            body=body).execute(num_retries=num_retries)

如错误消息所示:目标数据集的流式摄取已禁用。

您要么尝试写入列为 public 且只读的数据集,要么由于某种原因被 BigQuery 禁用,您可以联系他们。

您可以联系支持人员here or in case you know it's a known bug, you can try posting an issue here

正如 Felipe Hoffa 所指出的,此功能目前在欧洲数据集上未启用。