From 77ce8950f41f219e401d2ec04c1fd60dbffcd156 Mon Sep 17 00:00:00 2001 From: Neenu1995 Date: Fri, 8 May 2026 14:58:03 -0400 Subject: [PATCH 1/4] fix(bqjdbc): optimize meetsReadRatio latency to achieve faster page counting --- .../google-cloud-bigquery-jdbc/.gitignore | 1 + .../bigquery/jdbc/BigQueryJdbcUrlUtility.java | 2 +- .../bigquery/jdbc/BigQueryStatement.java | 19 +++- .../bigquery/jdbc/BigQueryStatementTest.java | 92 +++++++++++++++++++ 4 files changed, 111 insertions(+), 3 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery-jdbc/.gitignore b/java-bigquery/google-cloud-bigquery-jdbc/.gitignore index 2c4fba513e11..40a3476b598a 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/.gitignore +++ b/java-bigquery/google-cloud-bigquery-jdbc/.gitignore @@ -2,6 +2,7 @@ drivers/** target-it/** *logs*/** **/ITBigQueryJDBCLocalTest.java +**/BigQueryStatementE2EBenchmark.java tools/**/*.class tools/**/*.jfr \ No newline at end of file diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java index 89a2b8b5cb8c..c2ade0928f03 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java @@ -72,7 +72,7 @@ protected boolean removeEldestEntry(Map.Entry> eldes static final String QUERY_PROPERTIES_NAME = "QueryProperties"; static final int DEFAULT_HTAPI_ACTIVATION_RATIO_VALUE = 2; static final String HTAPI_MIN_TABLE_SIZE_PROPERTY_NAME = "HighThroughputMinTableSize"; - static final int DEFAULT_HTAPI_MIN_TABLE_SIZE_VALUE = 100; + static final int DEFAULT_HTAPI_MIN_TABLE_SIZE_VALUE = 10000; static final int DEFAULT_OAUTH_TYPE_VALUE = -1; static final String LOCATION_PROPERTY_NAME = "Location"; static final String ENDPOINT_OVERRIDES_PROPERTY_NAME = "EndpointOverrides"; diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java index e2dab7b31678..8e0d80616fbd 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java @@ -55,7 +55,6 @@ import com.google.cloud.bigquery.storage.v1.ReadSession; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterators; import com.google.common.util.concurrent.Uninterruptibles; import java.lang.ref.ReferenceQueue; import java.sql.Connection; @@ -952,7 +951,23 @@ private boolean meetsReadRatio(TableResult results) { // below log iterates and counts. This is inefficient and we may eventually want to expose // PageSize with TableResults // TODO(Obada): Scope for performance optimization. - int pageSize = Iterators.size(results.getValues().iterator()); + int pageSize; + Iterable values = results.getValues(); + if (values instanceof java.util.Collection) { + pageSize = ((java.util.Collection) values).size(); + } else { + // O(1) Fast Page Size Approximation: + // If the values iterable is not a collection, approximate the page size rather than + // performing a slow O(N) iteration over the entire page of query results. + pageSize = (int) Math.min(totalRows, querySettings.getMaxResultPerPage()); + } + + // SAFEGUARD: If all data has already been retrieved in the first page, + // NEVER switch to the Read API as it would discard in-memory data and cause a double-fetch. + if (totalRows <= pageSize) { + return false; + } + return totalRows / pageSize > querySettings.getHighThroughputActivationRatio(); } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java index 9fef90c69a4d..ed5ebf400153 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java @@ -494,4 +494,96 @@ public void testGetStatementType(boolean isReadOnlyTokenUsed) throws Exception { verify(bigquery, isReadOnlyTokenUsed ? Mockito.never() : Mockito.times(1)) .create(any(JobInfo.class)); } + + @Test + public void testUseReadAPI_SafeguardSmallDataset() throws SQLException { + // Setup: totalRows <= pageSize, so it should not activate the Read API + doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); + doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); + doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); + doReturn(1000L).when(bigQueryConnection).getMaxResults(); + + BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); + TableResult tableResult = mock(TableResult.class); + doReturn(50L).when(tableResult).getTotalRows(); + + // Standard java collection in values + java.util.List valuesList = + new java.util.ArrayList<>(); + for (int i = 0; i < 50; i++) { + valuesList.add(mock(com.google.cloud.bigquery.FieldValueList.class)); + } + doReturn(valuesList).when(tableResult).getValues(); + + boolean useReadApi = statement.useReadAPI(tableResult); + assertThat(useReadApi).isFalse(); + } + + @Test + public void testUseReadAPI_MeetsRatioCollection() throws SQLException { + // Setup: totalRows = 500, pageSize = 100, MinTableSize = 100, ActivationRatio = 2 + // ratio = 5 > 2, should activate Read API + doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); + doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); + doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); + doReturn(1000L).when(bigQueryConnection).getMaxResults(); + + BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); + TableResult tableResult = mock(TableResult.class); + doReturn(500L).when(tableResult).getTotalRows(); + + java.util.List valuesList = + new java.util.ArrayList<>(); + for (int i = 0; i < 100; i++) { + valuesList.add(mock(com.google.cloud.bigquery.FieldValueList.class)); + } + doReturn(valuesList).when(tableResult).getValues(); + + boolean useReadApi = statement.useReadAPI(tableResult); + assertThat(useReadApi).isTrue(); + } + + @Test + public void testUseReadAPI_FailsMinTableSize() throws SQLException { + // Setup: totalRows = 80 < MinTableSize (100) + doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); + doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); + doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); + doReturn(1000L).when(bigQueryConnection).getMaxResults(); + + BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); + TableResult tableResult = mock(TableResult.class); + doReturn(80L).when(tableResult).getTotalRows(); + + java.util.List valuesList = + new java.util.ArrayList<>(); + for (int i = 0; i < 20; i++) { + valuesList.add(mock(com.google.cloud.bigquery.FieldValueList.class)); + } + doReturn(valuesList).when(tableResult).getValues(); + + boolean useReadApi = statement.useReadAPI(tableResult); + assertThat(useReadApi).isFalse(); + } + + @Test + public void testUseReadAPI_NonCollectionApproximation() throws SQLException { + // Setup: totalRows = 500, MinTableSize = 100, ActivationRatio = 2, maxResultPerPage = 100 + // results.getValues() returns custom non-collection Iterable (ratio = 500/100 = 5 > 2) + doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); + doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); + doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); + doReturn(100L).when(bigQueryConnection).getMaxResults(); // maxResultPerPage = 100 + + BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); + TableResult tableResult = mock(TableResult.class); + doReturn(500L).when(tableResult).getTotalRows(); + + // Mock non-collection iterable + Iterable mockIterable = mock(Iterable.class); + doReturn(mockIterable).when(tableResult).getValues(); + + boolean useReadApi = statement.useReadAPI(tableResult); + assertThat(useReadApi).isTrue(); + } } From 8e1803247a8f54ebde4826cad50e6c1f52222f1c Mon Sep 17 00:00:00 2001 From: Neenu1995 Date: Fri, 8 May 2026 15:14:26 -0400 Subject: [PATCH 2/4] lint --- .../bigquery/jdbc/BigQueryStatement.java | 9 ++++++-- .../bigquery/jdbc/BigQueryStatementTest.java | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java index 8e0d80616fbd..f6b2817890fa 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java @@ -951,7 +951,7 @@ private boolean meetsReadRatio(TableResult results) { // below log iterates and counts. This is inefficient and we may eventually want to expose // PageSize with TableResults // TODO(Obada): Scope for performance optimization. - int pageSize; + long pageSize; Iterable values = results.getValues(); if (values instanceof java.util.Collection) { pageSize = ((java.util.Collection) values).size(); @@ -959,7 +959,12 @@ private boolean meetsReadRatio(TableResult results) { // O(1) Fast Page Size Approximation: // If the values iterable is not a collection, approximate the page size rather than // performing a slow O(N) iteration over the entire page of query results. - pageSize = (int) Math.min(totalRows, querySettings.getMaxResultPerPage()); + pageSize = Math.min(totalRows, querySettings.getMaxResultPerPage()); + } + + // Prevent division by zero or negative pageSize due to potential overflows/empty sets: + if (pageSize <= 0) { + pageSize = 1; } // SAFEGUARD: If all data has already been retrieved in the first page, diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java index ed5ebf400153..3b4ade464b8a 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java @@ -586,4 +586,27 @@ public void testUseReadAPI_NonCollectionApproximation() throws SQLException { boolean useReadApi = statement.useReadAPI(tableResult); assertThat(useReadApi).isTrue(); } + + @Test + public void testUseReadAPI_ZeroPageSizeDivisionByZeroSafeguard() throws SQLException { + // Setup: totalRows = 500, MinTableSize = 100, ActivationRatio = 2, maxResultPerPage = 0 + // Verify that the division by zero or negative values check safely guards and falls back to + // pageSize = 1 + doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); + doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); + doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); + doReturn(0L).when(bigQueryConnection).getMaxResults(); // maxResultPerPage = 0 + + BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); + TableResult tableResult = mock(TableResult.class); + doReturn(500L).when(tableResult).getTotalRows(); + + // Mock non-collection iterable to force the Math.min path which yields 0 + Iterable mockIterable = mock(Iterable.class); + doReturn(mockIterable).when(tableResult).getValues(); + + // This should not throw ArithmeticException (/ by zero) and should evaluate safely + boolean useReadApi = statement.useReadAPI(tableResult); + assertThat(useReadApi).isTrue(); // ratio = 500 / 1 = 500 > 2 -> true + } } From 7214d956c7c9b6fc24a709b9ae3344e44094042b Mon Sep 17 00:00:00 2001 From: Neenu1995 Date: Mon, 11 May 2026 12:19:28 -0400 Subject: [PATCH 3/4] fix logic --- .../bigquery/jdbc/BigQueryStatement.java | 29 +++------ .../bigquery/jdbc/BigQueryStatementTest.java | 60 +++++++------------ 2 files changed, 27 insertions(+), 62 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java index f6b2817890fa..b224a51b67b1 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java @@ -943,36 +943,21 @@ private boolean meetsReadRatio(TableResult results) { LOG.finest("++enter++"); long totalRows = results.getTotalRows(); - if (totalRows == 0 || totalRows < querySettings.getHighThroughputMinTableSize()) { + // SAFEGUARD: If all data has already been retrieved in the first page, + // NEVER switch to the Read API as it would discard in-memory data and cause a double-fetch. + if (totalRows == 0 + || totalRows < querySettings.getHighThroughputMinTableSize() + || !results.hasNextPage()) { return false; } - // TODO(BQ Team): TableResult doesnt expose the number of records in the current page, hence the - // below log iterates and counts. This is inefficient and we may eventually want to expose - // PageSize with TableResults - // TODO(Obada): Scope for performance optimization. - long pageSize; - Iterable values = results.getValues(); - if (values instanceof java.util.Collection) { - pageSize = ((java.util.Collection) values).size(); - } else { - // O(1) Fast Page Size Approximation: - // If the values iterable is not a collection, approximate the page size rather than - // performing a slow O(N) iteration over the entire page of query results. - pageSize = Math.min(totalRows, querySettings.getMaxResultPerPage()); - } + long pageSize = querySettings.getMaxResultPerPage(); - // Prevent division by zero or negative pageSize due to potential overflows/empty sets: + // Prevent division by zero due to potential overflows/empty sets: if (pageSize <= 0) { pageSize = 1; } - // SAFEGUARD: If all data has already been retrieved in the first page, - // NEVER switch to the Read API as it would discard in-memory data and cause a double-fetch. - if (totalRows <= pageSize) { - return false; - } - return totalRows / pageSize > querySettings.getHighThroughputActivationRatio(); } diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java index 3b4ade464b8a..de81c9c45311 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java @@ -497,7 +497,7 @@ public void testGetStatementType(boolean isReadOnlyTokenUsed) throws Exception { @Test public void testUseReadAPI_SafeguardSmallDataset() throws SQLException { - // Setup: totalRows <= pageSize, so it should not activate the Read API + // Setup: totalRows < MinTableSize, so it should not activate the Read API doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); @@ -520,9 +520,9 @@ public void testUseReadAPI_SafeguardSmallDataset() throws SQLException { } @Test - public void testUseReadAPI_MeetsRatioCollection() throws SQLException { - // Setup: totalRows = 500, pageSize = 100, MinTableSize = 100, ActivationRatio = 2 - // ratio = 5 > 2, should activate Read API + public void testUseReadAPI_SafeguardNoNextPage() throws SQLException { + // Setup: totalRows = 500 > MinTableSize (100), but hasNextPage() is false. + // Safeguard should prevent double-fetching and not activate the Read API. doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); @@ -531,67 +531,50 @@ public void testUseReadAPI_MeetsRatioCollection() throws SQLException { BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); TableResult tableResult = mock(TableResult.class); doReturn(500L).when(tableResult).getTotalRows(); - - java.util.List valuesList = - new java.util.ArrayList<>(); - for (int i = 0; i < 100; i++) { - valuesList.add(mock(com.google.cloud.bigquery.FieldValueList.class)); - } - doReturn(valuesList).when(tableResult).getValues(); + doReturn(false).when(tableResult).hasNextPage(); boolean useReadApi = statement.useReadAPI(tableResult); - assertThat(useReadApi).isTrue(); + assertThat(useReadApi).isFalse(); } @Test - public void testUseReadAPI_FailsMinTableSize() throws SQLException { - // Setup: totalRows = 80 < MinTableSize (100) + public void testUseReadAPI_MeetsRatio() throws SQLException { + // Setup: totalRows = 500, maxResultPerPage = 100, MinTableSize = 100, ActivationRatio = 2 + // ratio = 5 > 2, should activate Read API doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); - doReturn(1000L).when(bigQueryConnection).getMaxResults(); + doReturn(100L).when(bigQueryConnection).getMaxResults(); BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); TableResult tableResult = mock(TableResult.class); - doReturn(80L).when(tableResult).getTotalRows(); - - java.util.List valuesList = - new java.util.ArrayList<>(); - for (int i = 0; i < 20; i++) { - valuesList.add(mock(com.google.cloud.bigquery.FieldValueList.class)); - } - doReturn(valuesList).when(tableResult).getValues(); + doReturn(500L).when(tableResult).getTotalRows(); + doReturn(true).when(tableResult).hasNextPage(); boolean useReadApi = statement.useReadAPI(tableResult); - assertThat(useReadApi).isFalse(); + assertThat(useReadApi).isTrue(); } @Test - public void testUseReadAPI_NonCollectionApproximation() throws SQLException { - // Setup: totalRows = 500, MinTableSize = 100, ActivationRatio = 2, maxResultPerPage = 100 - // results.getValues() returns custom non-collection Iterable (ratio = 500/100 = 5 > 2) + public void testUseReadAPI_FailsMinTableSize() throws SQLException { + // Setup: totalRows = 80 < MinTableSize (100) doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); - doReturn(100L).when(bigQueryConnection).getMaxResults(); // maxResultPerPage = 100 + doReturn(1000L).when(bigQueryConnection).getMaxResults(); BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); TableResult tableResult = mock(TableResult.class); - doReturn(500L).when(tableResult).getTotalRows(); - - // Mock non-collection iterable - Iterable mockIterable = mock(Iterable.class); - doReturn(mockIterable).when(tableResult).getValues(); + doReturn(80L).when(tableResult).getTotalRows(); boolean useReadApi = statement.useReadAPI(tableResult); - assertThat(useReadApi).isTrue(); + assertThat(useReadApi).isFalse(); } @Test public void testUseReadAPI_ZeroPageSizeDivisionByZeroSafeguard() throws SQLException { // Setup: totalRows = 500, MinTableSize = 100, ActivationRatio = 2, maxResultPerPage = 0 - // Verify that the division by zero or negative values check safely guards and falls back to - // pageSize = 1 + // Verify that the division by zero check safely guards and falls back to pageSize = 1 doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI(); doReturn(100).when(bigQueryConnection).getHighThroughputMinTableSize(); doReturn(2).when(bigQueryConnection).getHighThroughputActivationRatio(); @@ -600,10 +583,7 @@ public void testUseReadAPI_ZeroPageSizeDivisionByZeroSafeguard() throws SQLExcep BigQueryStatement statement = new BigQueryStatement(bigQueryConnection); TableResult tableResult = mock(TableResult.class); doReturn(500L).when(tableResult).getTotalRows(); - - // Mock non-collection iterable to force the Math.min path which yields 0 - Iterable mockIterable = mock(Iterable.class); - doReturn(mockIterable).when(tableResult).getValues(); + doReturn(true).when(tableResult).hasNextPage(); // This should not throw ArithmeticException (/ by zero) and should evaluate safely boolean useReadApi = statement.useReadAPI(tableResult); From 581773a3cf521b730f7a52d52e34ce8bdb591861 Mon Sep 17 00:00:00 2001 From: Neenu1995 Date: Mon, 11 May 2026 12:26:18 -0400 Subject: [PATCH 4/4] fix imports --- .../google/cloud/bigquery/jdbc/BigQueryStatementTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java index de81c9c45311..033cb72dcf8c 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java +++ b/java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java @@ -32,6 +32,7 @@ import com.google.cloud.bigquery.BigQueryOptions; import com.google.cloud.bigquery.Field; import com.google.cloud.bigquery.FieldList; +import com.google.cloud.bigquery.FieldValueList; import com.google.cloud.bigquery.Job; import com.google.cloud.bigquery.JobId; import com.google.cloud.bigquery.JobInfo; @@ -55,6 +56,7 @@ import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -508,10 +510,9 @@ public void testUseReadAPI_SafeguardSmallDataset() throws SQLException { doReturn(50L).when(tableResult).getTotalRows(); // Standard java collection in values - java.util.List valuesList = - new java.util.ArrayList<>(); + List valuesList = new ArrayList<>(); for (int i = 0; i < 50; i++) { - valuesList.add(mock(com.google.cloud.bigquery.FieldValueList.class)); + valuesList.add(mock(FieldValueList.class)); } doReturn(valuesList).when(tableResult).getValues();