This is an automated email from the ASF dual-hosted git repository.

tbonelee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f16789d4b [ZEPPELIN-5758] Raise BigQuery HTTP client timeout so large 
wait_time values work
2f16789d4b is described below

commit 2f16789d4b4d0faa29fb861698c2e13cea89dd82
Author: HwangRock <[email protected]>
AuthorDate: Sun Oct 18 15:34:13 2026 +0900

    [ZEPPELIN-5758] Raise BigQuery HTTP client timeout so large wait_time 
values work
    
    ### What is this PR for?
    `zeppelin.bigquery.wait_time` is passed to BigQuery's `jobs.query` as the 
server-side `timeoutMs`, telling the server how long to wait for the query 
result before replying. The HTTP client (`NetHttpTransport`), however, kept its 
default read timeout (~20s). As a result, setting `wait_time` beyond that 
threshold threw `java.net.SocketTimeoutException: Read timed out` before the 
server responded, making the setting unusable above ~30s.
    
    This wraps the Bigquery client credential in an `HttpRequestInitializer` 
that sets the connect/read timeouts to 200s. BigQuery's `getQueryResults` 
always returns within ~200s regardless of whether the job has completed, so a 
larger timeout provides no value. The credential's own `initialize()` is still 
invoked first, so OAuth token refresh behavior is preserved.
    
    ### What type of PR is it?
    Bug Fix
    
    ### Todos
    * [x] - Wrap the client credential with connect/read timeouts
    * [x] - Add a unit test
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/ZEPPELIN-5758
    
    ### How should this be tested?
    * `./mvnw test -pl bigquery --am -Dtest=BigQueryInterpreterTimeoutTest`
    * `BigQueryInterpreterTimeoutTest` verifies the initializer delegates to 
the wrapped credential and applies the 200s connect/read timeouts. It is a 
separate class because `BigQueryInterpreterTest` is excluded from the build (it 
needs live BigQuery credentials).
    
    ### Questions:
    * Does the license files need to be updated? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Closes #5545 from HwangRock/ZEPPELIN-5758-bigquery-read-timeout.
    
    Signed-off-by: ChanHo Lee <[email protected]>
---
 .../zeppelin/bigquery/BigQueryInterpreter.java     | 16 +++++++-
 .../bigquery/BigQueryInterpreterTimeoutTest.java   | 47 ++++++++++++++++++++++
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git 
a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java 
b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
index 1daee871d0..e52720718a 100644
--- 
a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
+++ 
b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
@@ -17,6 +17,7 @@
 package org.apache.zeppelin.bigquery;
 
 import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
+import com.google.api.client.http.HttpRequestInitializer;
 import com.google.api.client.http.HttpTransport;
 import com.google.api.client.http.javanet.NetHttpTransport;
 import com.google.api.client.json.GenericJson;
@@ -130,6 +131,19 @@ public class BigQueryInterpreter extends Interpreter {
     }
   }
 
+  // BigQuery getQueryResults responds within ~200 seconds regardless of job 
completion,
+  // so a 200 second client timeout covers any wait_time.
+  static final int CONNECTION_TIMEOUT_MS = 200 * 1000;
+  static final int READ_TIMEOUT_MS = 200 * 1000;
+
+  static HttpRequestInitializer setTimeout(final HttpRequestInitializer 
requestInitializer) {
+    return request -> {
+      requestInitializer.initialize(request);
+      request.setConnectTimeout(CONNECTION_TIMEOUT_MS);
+      request.setReadTimeout(READ_TIMEOUT_MS);
+    };
+  }
+
   //Function that Creates an authorized client to Google Bigquery.
   private static Bigquery createAuthorizedClient() throws IOException {
     HttpTransport transport = new NetHttpTransport();
@@ -141,7 +155,7 @@ public class BigQueryInterpreter extends Interpreter {
       credential = credential.createScoped(bigqueryScopes);
     }
 
-    return new Bigquery.Builder(transport, jsonFactory, credential)
+    return new Bigquery.Builder(transport, jsonFactory, setTimeout(credential))
         .setApplicationName("Zeppelin/1.0 (GPN:Apache Zeppelin;)").build();
   }
 
diff --git 
a/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTimeoutTest.java
 
b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTimeoutTest.java
new file mode 100644
index 0000000000..0f0b5ee1fb
--- /dev/null
+++ 
b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTimeoutTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zeppelin.bigquery;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import com.google.api.client.http.GenericUrl;
+import com.google.api.client.http.HttpRequest;
+import com.google.api.client.http.HttpRequestInitializer;
+import com.google.api.client.http.javanet.NetHttpTransport;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+class BigQueryInterpreterTimeoutTest {
+
+  @Test
+  void testSetTimeoutAppliesClientTimeoutsAndDelegates() throws Exception {
+    AtomicBoolean delegated = new AtomicBoolean(false);
+    HttpRequestInitializer delegate = request -> delegated.set(true);
+    HttpRequest request = new NetHttpTransport().createRequestFactory()
+        .buildGetRequest(new GenericUrl("https://example.com";));
+
+    BigQueryInterpreter.setTimeout(delegate).initialize(request);
+
+    assertTrue(delegated.get());
+    assertEquals(200000, request.getConnectTimeout());
+    assertEquals(200000, request.getReadTimeout());
+  }
+}

Reply via email to