【问题标题】:BigQuery: Encountered an error while globbing file patternBigQuery:在 globbing 文件模式时遇到错误
【发布时间】:2016-11-19 10:31:09
【问题描述】:

我使用 Google 电子表格中的数据查询了一个联合表。遵循问题 720 中的建议 https://code.google.com/p/google-bigquery/issues/detail?id=720 我创建了以下代码:

    Set<String> scopes = new HashSet<>();
    scopes.add(BigqueryScopes.BIGQUERY);
    scopes.add("https://www.googleapis.com/auth/drive");
    scopes.add("https://www.googleapis.com/auth/spreadsheets");
    final HttpTransport transport= new NetHttpTransport();
    final JsonFactory jsonFactory= new JacksonFactory();
    GoogleCredential credential = new GoogleCredential.Builder()
                .setTransport(transport).setJsonFactory(jsonFactory)
                .setServiceAccountId(GC_CREDENTIALS_ACCOUNT_EMAIL)
                .setServiceAccountScopes(scopes)
                .setServiceAccountPrivateKey(getPrivateKey())       
                .build();
    String omgsql = "SELECT * FROM [<myproject>:<mydataset>.failures] LIMIT 1000";
    JobReference jobIdomg = startQuery(bigquery, "<myproject>", omgsql);

    // Poll for Query Results, return result output
    Job completedJobomg = checkQueryResults(bigquery, "<myproject>", jobIdomg);
    GetQueryResultsResponse queryResultomg = bigquery.jobs()
        .getQueryResults(
            "<myproject>", completedJobomg
                .getJobReference()
                .getJobId()
        ).execute();
    List<TableRow> rowsomg = queryResultomg.getRows();

没有 https://www.googleapis.com/auth/drive 作用域的作业在插入后立即失败,如果有它 - 完成时失败。

Inserting Query Job: SELECT * FROM [<myproject>:<mydataset>.failures] LIMIT 1000
Job ID of Query Job is: job_S3-fY5jrb4P3UhVgNGeRkDYQofg
Job status (194ms) job_S3-fY5jrb4P3UhVgNGeRkDYQofg: RUNNING
Job status (1493ms) job_S3-fY5jrb4P3UhVgNGeRkDYQofg: RUNNING
Job status (2686ms) job_S3-fY5jrb4P3UhVgNGeRkDYQofg: RUNNING
...
Job status (29881ms) job_S3-fY5jrb4P3UhVgNGeRkDYQofg: DONE
Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "location" : "/gdrive/id/1T4qNgi9vFJF4blK4jddYf8XlfT6uDiqNpTExWf1NMyY",
    "locationType" : "other",
    "message" : "Encountered an error while globbing file pattern.",
    "reason" : "invalid"
  } ],
  "message" : "Encountered an error while globbing file pattern."
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)

所以这里的问题 - 我还缺少什么?还是只是一个大查询错误?

【问题讨论】:

    标签: google-bigquery


    【解决方案1】:

    好的,经过一天的实验 - 您用来获取 Google 凭据的帐户应该可以访问在其上创建外部表的文件。希望这会对某人有所帮助。

    【讨论】:

    • 嘿阿列克谢。您能告诉我如何添加该访问权限吗?我正在尝试从 python 查询大查询表。我能够无缝查询一些表。但是,对于几张桌子,我遇到了与您相同的错误。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 2017-04-05
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 2017-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多