From 10e2c326477c735f89dc17f690942bf6fb45fb29 Mon Sep 17 00:00:00 2001 From: Jin Seop Kim Date: Thu, 17 Sep 2026 07:02:44 -0400 Subject: [PATCH 1/3] chore(bigquery): add Arrow performance benchmarks to QueryBenchmark --- .../QueryBenchmark.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java b/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java index 79aa484d8b69..048996df490a 100644 --- a/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java +++ b/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import org.apache.arrow.vector.VectorSchemaRoot; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -93,4 +94,30 @@ private void queryPerform(String queries, Blackhole blackhole) throws Exception public void query(QueryParams queryParams, Blackhole blackhole) throws Exception { queryPerform(queryParams.queries, blackhole); } + + @Benchmark + public void queryWithArrowRowBased(QueryParams queryParams, Blackhole blackhole) + throws Exception { + QueryJobConfiguration config = + QueryJobConfiguration.newBuilder(queryParams.queries) + .setUseLegacySql(false) + .setQueryResultsFormat(QueryResultsFormat.ARROW) + .build(); + TableResult result = bigquery.query(config); + for (FieldValueList row : result.iterateAll()) { + blackhole.consume(row); + } + } + + @Benchmark + public void queryWithArrowZeroCopy(QueryParams queryParams, Blackhole blackhole) + throws Exception { + QueryJobConfiguration config = + QueryJobConfiguration.newBuilder(queryParams.queries).setUseLegacySql(false).build(); + try (ArrowQueryResult result = bigquery.queryArrow(config)) { + for (VectorSchemaRoot root : result) { + blackhole.consume(root); + } + } + } } From f2302cae70ef06d03092ec61bfd51957aaed2558 Mon Sep 17 00:00:00 2001 From: Jin Seop Kim Date: Thu, 17 Sep 2026 07:04:57 -0400 Subject: [PATCH 2/3] chore(bigquery): explicitly set QueryResultsFormat.ARROW in queryWithArrowZeroCopy benchmark --- .../main/java/com.google.cloud.bigquery/QueryBenchmark.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java b/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java index 048996df490a..5472e684cc35 100644 --- a/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java +++ b/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java @@ -113,7 +113,10 @@ public void queryWithArrowRowBased(QueryParams queryParams, Blackhole blackhole) public void queryWithArrowZeroCopy(QueryParams queryParams, Blackhole blackhole) throws Exception { QueryJobConfiguration config = - QueryJobConfiguration.newBuilder(queryParams.queries).setUseLegacySql(false).build(); + QueryJobConfiguration.newBuilder(queryParams.queries) + .setUseLegacySql(false) + .setQueryResultsFormat(QueryResultsFormat.ARROW) + .build(); try (ArrowQueryResult result = bigquery.queryArrow(config)) { for (VectorSchemaRoot root : result) { blackhole.consume(root); From 5af88f8b2736f77371860fcb20d3e6490bcfbd61 Mon Sep 17 00:00:00 2001 From: Jin Seop Kim Date: Fri, 18 Sep 2026 18:02:21 -0400 Subject: [PATCH 3/3] chore(bigquery): add simple-path first-batch benchmarks to QueryBenchmark --- .../QueryBenchmark.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java b/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java index 5472e684cc35..bdab12d62a44 100644 --- a/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java +++ b/java-bigquery/benchmark/src/main/java/com.google.cloud.bigquery/QueryBenchmark.java @@ -16,6 +16,7 @@ package com.google.cloud.bigquery; +import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.arrow.vector.VectorSchemaRoot; @@ -123,4 +124,44 @@ public void queryWithArrowZeroCopy(QueryParams queryParams, Blackhole blackhole) } } } + + @Benchmark + public void querySimplePath(QueryParams queryParams, Blackhole blackhole) throws Exception { + TableResult result = + bigquery.query( + QueryJobConfiguration.newBuilder(queryParams.queries).setUseLegacySql(false).build()); + for (FieldValueList row : result.getValues()) { + blackhole.consume(row); + } + } + + @Benchmark + public void queryWithArrowRowBasedSimplePath(QueryParams queryParams, Blackhole blackhole) + throws Exception { + QueryJobConfiguration config = + QueryJobConfiguration.newBuilder(queryParams.queries) + .setUseLegacySql(false) + .setQueryResultsFormat(QueryResultsFormat.ARROW) + .build(); + TableResult result = bigquery.query(config); + for (FieldValueList row : result.getValues()) { + blackhole.consume(row); + } + } + + @Benchmark + public void queryWithArrowZeroCopySimplePath(QueryParams queryParams, Blackhole blackhole) + throws Exception { + QueryJobConfiguration config = + QueryJobConfiguration.newBuilder(queryParams.queries) + .setUseLegacySql(false) + .setQueryResultsFormat(QueryResultsFormat.ARROW) + .build(); + try (ArrowQueryResult result = bigquery.queryArrow(config)) { + Iterator it = result.iterator(); + if (it.hasNext()) { + blackhole.consume(it.next()); + } + } + } }