我正在使用分页并参考此链接
https://cloud.google.com/bigquery/docs/paging-results#java
我的示例代码如下所示
public void readAggBatchBq() throws InterruptedException {
BigQuery bq = bqConfig.bigQuery();
TableId tableId = TableId.of(dataset, table);
String query = "SELECT * from `test.historical_data`";
QueryJobConfiguration queryConfig =
QueryJobConfiguration.newBuilder(query)
// save results into a table.
//.setDestinationTable(tableId)
//.setWriteDisposition(JobInfo.WriteDisposition.WRITE_APPEND)
.build();
bq.query(queryConfig);
TableResult results =
bq.listTableData(tableId, BigQuery.TableDataListOption.pageSize(4));
// First Page
while(results.hasNextPage()) {
Schema sch = results.getSchema();
results
.getValues()
.forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString())));
results = results.getNextPage();
}
results = results.getNextPage();
System.out.println("Query pagination performed successfully.");
当我从结果中读取架构时,架构为空。有什么问题吗?
可能在
tableId
标识的表中没有数据。
尝试取消注释
//.setDestinationTable(tableId)