我试图从job.list中检索每个作业的查询但是JobConfiguration没有该字段。
BigQuery bigQuery = bigqueryClientServiceFactory.getClientService(dataStoreId);
Page<Job> listJobs = bigQuery.listJobs(JobListOption.pageSize(100),JobListOption.fields(JobField.values()));
for(Job job:listJobs.iterateAll()){
com.google.cloud.bigquery.JobConfiguration configuration = job.getConfiguration();
}
答案 0 :(得分:2)
您需要将JobConfiguration
转换为QueryJobConfiguration
并调用getQuery()
方法:
public static void main(String[] args) {
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
Page<Job> listJobs = bigquery.listJobs(BigQuery.JobListOption.pageSize(100));
for(Job job:listJobs.iterateAll()){
if (job.getConfiguration() instanceof QueryJobConfiguration){
QueryJobConfiguration queryConfig = job.getConfiguration();
System.out.println(queryConfig.getQuery());
}
}
}