【问题标题】:BigQuery access through service account fails with dataset not found in location US通过服务帐户访问 BigQuery 失败,在美国位置找不到数据集
【发布时间】:2019-09-11 14:44:27
【问题描述】:

我更改了程序的服务密钥,现在出现以下错误:

com.google.cloud.bigquery.BigQueryException: Not found: Dataset test-123:flights was not found in location US
at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.translate(HttpBigQueryRpc.java:106)
at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.getQueryResults(HttpBigQueryRpc.java:584)
at com.google.cloud.bigquery.BigQueryImpl$34.call(BigQueryImpl.java:1203)
at com.google.cloud.bigquery.BigQueryImpl$34.call(BigQueryImpl.java:1198)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
at com.google.cloud.bigquery.BigQueryImpl.getQueryResults(BigQueryImpl.java:1197)
at com.google.cloud.bigquery.BigQueryImpl.getQueryResults(BigQueryImpl.java:1181)
at com.google.cloud.bigquery.Job$1.call(Job.java:329)
at com.google.cloud.bigquery.Job$1.call(Job.java:326)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
at com.google.cloud.RetryHelper.poll(RetryHelper.java:64)
at com.google.cloud.bigquery.Job.waitForQueryResults(Job.java:325)
at com.google.cloud.bigquery.Job.getQueryResults(Job.java:291)
at com.google.cloud.bigquery.BigQueryImpl.query(BigQueryImpl.java:1168)

数据集实际上位于欧盟位置。我查看了项目的查询历史记录,执行并引发错误的查询的位置为 US。

如果我使用旧密钥,一切都会按预期工作。新密钥具有以下作用: 大查询管理员

我正在使用以下库和代码: “com.google.cloud:google-cloud-bigquery:1.90.0”

val query = "$label MERGE $dataset.$tableName T " +
            "USING $tmpTableName S " +
            "ON T.$mergeColumnName = S.$mergeColumnName " +
            "WHEN MATCHED THEN ... "

    val queryConfig = QueryJobConfiguration.newBuilder(query)
            .addTableDefinition(tmpTableName,
                    ExternalTableDefinition.newBuilder(sourceFile, schema, format)
                            .setCompression("GZIP")
                            .build())
            .build();
            bigQuery.query(queryConfig)

有没有办法在代码中指定位置或为服务帐户指定默认位置?

有趣的是,以下代码列出了数据集:

val datasets = bigQuery.listDatasets(DatasetListOption.pageSize(100))
    for (dataset in datasets.iterateAll()) {
        log.info("$dataset")
    }

【问题讨论】:

    标签: google-bigquery


    【解决方案1】:

    解决了:

    bigQuery.query(queryConfig, JobId.newBuilder().setLocation("EU").build())

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 2022-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多