“通过文件模式遇到错误”使用BigQuery API w / Google表格时出错 [英] "Encountered an error while globbing file pattern" error when using BigQuery API w/ Google Sheets

查看:108
本文介绍了“通过文件模式遇到错误”使用BigQuery API w / Google表格时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试访问来自BigQuery API的联合源代码(Google工作表)时,会引发以下错误:

When trying the access a federated source (Google sheets) from BigQuery API, the following error is thrown:

[..]
 "errorResult" : {
      "location" : "/gdrive/id/<removed_file_id>",
      "message" : "Encountered an error while globbing file pattern.",
      "reason" : "invalid"
    }
[..]



BigQuery中的表被设置为指向这个文件。它通过Web UI工作。只有当试图通过API查询表时,它才会扼杀上面的错误。

The table in BigQuery is set up to point to this file. It works via the Web UI. It is only when trying to query the table through the API does it then choke with the error above.

我猜它与权限有关。需要做些什么才能允许从API(联合源代码)访问BigQuery表(指向Google表格)?

I'm guessing it has something to do with permissions. What needs to be done to allow accessing a BigQuery table from the API which is a federated source (pointing to Google Sheets)?

推荐答案

当允许API查询BigQuery中的联合表时,需要遵循3个步骤 - 它指向Drive中的文件,即Google表格。

There are 3 steps to follow when allowing the API to query a federated table in BigQuery - which is pointing to a file in Drive i.e. Google Sheets.

其中两个步骤记录在此处(我错过了第二个 - 添加驱动器范围)。最后一项是将用于访问API的关联服务帐户电子邮件添加到文件本身。

Two of the steps are documented here (I was missing the 2nd one - adding the Drive scope). The last one is the add the associated service account email that is being used to access the API to the file itself.


  1. 使用Google Cloud通过平台控制台启用Google Drive API

  2. 请求 Google云端硬盘的OAuth范围,以及BigQuery的范围。

  3. 将您使用的服务帐户电子邮件添加到云端硬盘中的文件。它看起来像< project-id> - < fingerprint-hash> @ developer.gserviceaccount.com 。 查看权限就足够了。

  1. Use the Google Cloud Platform Console to enable the Google Drive API for the project making the API call.
  2. Request the OAuth scope for Google Drive in addition to the scope for BigQuery.
  3. Add the service account email that you are using to the file in Drive. It looks something like <project-id>-<fingerprint-hash>@developer.gserviceaccount.com. "View" permission is enough.

这篇关于“通过文件模式遇到错误”使用BigQuery API w / Google表格时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆