我更改了程序的服务密钥,现在出现以下错误:
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)
数据集实际上位于EU位置。我查看了项目的查询历史记录,执行并引发错误的查询的位置为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")
}
答案 0 :(得分:1)
通过以下方式解决:
bigQuery.query(queryConfig,JobId.newBuilder()。setLocation(“ EU”)。build())