Skip to content

Commit 133efbc

Browse files
committed
test(bigquery): add ITBigQueryTest integration tests for queryArrow
1 parent f56b410 commit 133efbc

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

  • java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it

‎java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.google.cloud.bigquery.Acl.DatasetAclEntity;
4646
import com.google.cloud.bigquery.Acl.Expr;
4747
import com.google.cloud.bigquery.Acl.User;
48+
import com.google.cloud.bigquery.ArrowQueryResult;
4849
import com.google.cloud.bigquery.BigQuery;
4950
import com.google.cloud.bigquery.BigQuery.DatasetField;
5051
import com.google.cloud.bigquery.BigQuery.DatasetListOption;
@@ -118,6 +119,7 @@
118119
import com.google.cloud.bigquery.QueryJobConfiguration.JobCreationMode;
119120
import com.google.cloud.bigquery.QueryJobConfiguration.Priority;
120121
import com.google.cloud.bigquery.QueryParameterValue;
122+
import com.google.cloud.bigquery.QueryResultsFormat;
121123
import com.google.cloud.bigquery.Range;
122124
import com.google.cloud.bigquery.RangePartitioning;
123125
import com.google.cloud.bigquery.Routine;
@@ -203,6 +205,7 @@
203205
import java.util.concurrent.TimeoutException;
204206
import java.util.logging.Level;
205207
import java.util.logging.Logger;
208+
import org.apache.arrow.vector.VectorSchemaRoot;
206209
import org.junit.jupiter.api.AfterAll;
207210
import org.junit.jupiter.api.BeforeAll;
208211
import org.junit.jupiter.api.Test;
@@ -7497,6 +7500,50 @@ void testQueryWithTimeout() throws InterruptedException {
74977500
assertTrue(millis < 1_000_000 * 2);
74987501
}
74997502

7503+
@Test
7504+
void testQueryResultsFormatArrow() throws InterruptedException {
7505+
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
7506+
BigQuery bigQuery = bigqueryHelper.getOptions().getService();
7507+
String query = "SELECT 1 as id, 'hello' as name, TIMESTAMP('2026-08-10T12:00:00Z') as ts";
7508+
QueryJobConfiguration config =
7509+
QueryJobConfiguration.newBuilder(query)
7510+
.setQueryResultsFormat(QueryResultsFormat.ARROW)
7511+
.setJobCreationMode(JobCreationMode.JOB_CREATION_OPTIONAL)
7512+
.build();
7513+
try (ArrowQueryResult result = bigQuery.queryArrow(config)) {
7514+
assertNotNull(result);
7515+
int batchCount = 0;
7516+
long totalRows = 0;
7517+
for (VectorSchemaRoot root : result) {
7518+
batchCount++;
7519+
totalRows += root.getRowCount();
7520+
assertEquals(1, root.getRowCount());
7521+
}
7522+
assertTrue(batchCount > 0);
7523+
assertEquals(1, totalRows);
7524+
}
7525+
}
7526+
7527+
@Test
7528+
void testQueryResultsFormatArrowMultiPage() throws InterruptedException {
7529+
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
7530+
BigQuery bigQuery = bigqueryHelper.getOptions().getService();
7531+
String query = "SELECT x FROM UNNEST(GENERATE_ARRAY(1, 15000)) AS x";
7532+
QueryJobConfiguration config =
7533+
QueryJobConfiguration.newBuilder(query)
7534+
.setQueryResultsFormat(QueryResultsFormat.ARROW)
7535+
.setJobCreationMode(JobCreationMode.JOB_CREATION_OPTIONAL)
7536+
.build();
7537+
try (ArrowQueryResult result = bigQuery.queryArrow(config)) {
7538+
assertNotNull(result);
7539+
long totalRows = 0;
7540+
for (VectorSchemaRoot root : result) {
7541+
totalRows += root.getRowCount();
7542+
}
7543+
assertEquals(15000, totalRows);
7544+
}
7545+
}
7546+
75007547
@Test
75017548
void testUniverseDomainWithInvalidUniverseDomain() {
75027549
RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();

0 commit comments

Comments
 (0)