Skip to content

Commit 71fba76

Browse files
committed
fix bad merge
1 parent 69f369b commit 71fba76

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -916,21 +916,24 @@ Thread populateArrowBufferedQueue(
916916

917917
/** Executes SQL query using either fast query path or read API */
918918
void processQueryResponse(String query, TableResult results) throws SQLException {
919-
LOG.finer(
920-
"API call completed{Query=%s, Parent Job ID=%s, Total rows=%s} ",
921-
query, results.getJobId(), results.getTotalRows());
922-
JobId currentJobId = results.getJobId();
923-
if (currentJobId == null) {
924-
LOG.fine("Standard API with Stateless query used.");
925-
this.currentResultSet = processJsonResultSet(results);
926-
} else if (useReadAPI(results)) {
927-
LOG.fine("HighThroughputAPI used.");
928-
LOG.info("HTAPI job ID: " + currentJobId.getJob());
929-
this.currentResultSet = processArrowResultSet(results);
930-
} else {
931-
// read API cannot be used.
932-
LOG.fine("Standard API used.");
933-
this.currentResultSet = processJsonResultSet(results);
919+
JobId jobId = results.getJobId();
920+
String queryId = results.getQueryId();
921+
LOG.info(
922+
"Processing query response. JobId: %s, QueryId: %s, Total rows: %s",
923+
jobId, queryId, results.getTotalRows());
924+
LOG.fine("Processing query response. Query: %s} ", query);
925+
926+
ResultSet resultSet = null;
927+
if (jobId != null && useReadAPI(results)) {
928+
try {
929+
LOG.info("Using ReadAPI to read the data.");
930+
resultSet = processArrowResultSet(results);
931+
} catch (SQLException e) {
932+
if (!isPermissionDeniedException(e)) {
933+
throw e;
934+
}
935+
LOG.log(Level.WARNING, "Permission denied for Read API, falling back to JSON API", e);
936+
}
934937
}
935938

936939
if (resultSet == null) {

java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryStatementTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ private ApiException mockApiException(StatusCode.Code code) {
574574
doReturn(statusCodeMock).when(apiExceptionMock).getStatusCode();
575575
doReturn(code).when(statusCodeMock).getCode();
576576
return apiExceptionMock;
577+
}
578+
579+
@Test
577580
public void testUseReadAPI_SafeguardSmallDataset() throws SQLException {
578581
// Setup: totalRows < MinTableSize, so it should not activate the Read API
579582
doReturn(true).when(bigQueryConnection).isEnableHighThroughputAPI();

0 commit comments

Comments
 (0)