diff --git a/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java b/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java index 190c9bcde..dc9a6a24f 100644 --- a/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java +++ b/samples/snippets/src/main/java/com/example/bigquery/QueryPagination.java @@ -59,15 +59,23 @@ public static void queryPagination(String datasetName, String tableName, String // First Page results - .iterateAll() - .forEach(row -> row.forEach(val -> System.out.printf("%s,", val.toString()))); + .getValues() + .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); if (results.hasNextPage()) { // Next Page + results + .getNextPage() + .getValues() + .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); + } + + if (results.hasNextPage()) { + // Remaining Pages results .getNextPage() .iterateAll() - .forEach(row -> row.forEach(val -> System.out.printf("%s,", val.toString()))); + .forEach(row -> row.forEach(val -> System.out.printf("%s,\n", val.toString()))); } System.out.println("Query pagination performed successfully.");