【发布时间】:2019-11-30 03:18:51
【问题描述】:
显然,在使用 BigQuery API 时,BigQuery 结果有一个cacheHit 属性。我试过找到这个属性,但我不确定我需要如何访问它。这是我使用 BigQuery API 的 Java 代码。 cacheHit 不是我得到的 TableResult tr 的属性:
try
{
QueryJobConfiguration queryJobConfiguration =
QueryJobConfiguration.newBuilder(
"mySQLqueryText"
)
.setUseLegacySql(false)
.setAllowLargeResults(false)
.setUseQueryCache(true)
.build();
try {
TableResult tr = bigQuery.query(queryJobConfiguration);
Iterable<FieldValueList> rowList = tr.getValues();
....
}
catch (BigQueryException e) {
// do stuff
}
} catch (InterruptedException e) {
e.printStackTrace();
}
我看了这个问题 - BigQuery cacheHit property
...但这不是 Java,我还没有找到我可以使用的任何 results() 属性,正如该问题中所建议的那样。
这里有一些关于 JobStatistics2 对象的文档,它显然有一个 cacheHit 属性。
我可以得到一个JobStatistics(不是一个JobStatistics2对象),像这样:
QueryJobConfiguration queryJobConfiguration =
QueryJobConfiguration.newBuilder(
"myQueryString"
)
.setUseLegacySql(false)
.setAllowLargeResults(false)
.setUseQueryCache(true)
.build();
JobId jobId = JobId.of(UUID.randomUUID().toString());
Job queryJob = bigQuery.create(JobInfo.newBuilder(queryJobConfiguration).setJobId(jobId).build());
try {
queryJob = queryJob.waitFor();
if (queryJob != null) {
JobStatistics js = queryJob.getStatistics();
Iterable<FieldValueList> rowList = bigQuery.query(queryJobConfiguration).getValues();
...但我在js 上看不到任何cacheHit 属性。当我尝试创建JobStatistics2 时,通过更改我实例化JobStatistics 的行,如下所示:
JobStatistics2 js = queryJob.getStatistics();
我收到一个错误Type parameter S has incompatible upper bounds: JobStatistics and JobStatistics2。这并不意味着什么,当我用谷歌搜索错误时,没有有用的结果。
我没有发现 Google 文档太有用。如代码示例所示,如何访问cacheHit 属性,并仍然获得我的rowList?
【问题讨论】:
标签: java google-cloud-platform google-bigquery