Skip to content

Commit

Permalink
refactor(samples): query pagination (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
Praful Makani committed Dec 9, 2020
1 parent 9c97f4a commit 7f2e5ca
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -57,11 +57,19 @@ public static void queryPagination(String datasetName, String tableName, String
TableResult results =
bigquery.listTableData(tableId, BigQuery.TableDataListOption.pageSize(20));

// First Page
results
.getNextPage()
.iterateAll()
.forEach(row -> row.forEach(val -> System.out.printf("%s,", val.toString())));

if (results.hasNextPage()) {
// Next Page
results
.getNextPage()
.iterateAll()
.forEach(row -> row.forEach(val -> System.out.printf("%s,", val.toString())));
}

System.out.println("Query pagination performed successfully.");
} catch (BigQueryException | InterruptedException e) {
System.out.println("Query not performed \n" + e.toString());
Expand Down

0 comments on commit 7f2e5ca

Please sign in to comment.