Skip to content

Commit ee48df1

Browse files
authored
Merge branch 'main' into migrate-java-cloud-bom
2 parents a083d67 + d7f1d1c commit ee48df1

8 files changed

Lines changed: 208 additions & 556 deletions

File tree

java-bigquery-jdbc/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@
157157
<pattern>org.json</pattern>
158158
<shadedPattern>com.google.bqjdbc.shaded.org.json</shadedPattern>
159159
</relocation>
160+
<relocation>
161+
<pattern>org.slf4j</pattern>
162+
<shadedPattern>com.google.bqjdbc.shaded.org.slf4j</shadedPattern>
163+
</relocation>
160164
<relocation>
161165
<pattern>io.grpc</pattern>
162166
<shadedPattern>com.google.bqjdbc.shaded.io.grpc</shadedPattern>

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,13 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
362362

363363
this.headerProvider = createHeaderProvider();
364364
this.bigQuery = getBigQueryConnection();
365-
// Fixed thread pool queues tasks to limit concurrent metadata calls and prevent API
366-
// throttling.
367-
this.metadataExecutor =
368-
BigQueryJdbcMdc.newFixedThreadPool(
369-
String.format("BQ-Metadata-%s", connectionId), metadataFetchThreadCount);
370365
// Cached pool executes queries immediately without queueing and reclaims all idle threads
371366
// when inactive, minimizing resources.
372367
this.queryExecutor =
373368
BigQueryJdbcMdc.newCachedThreadPool(String.format("BQ-Query-%s", connectionId));
369+
this.metadataExecutor =
370+
BigQueryJdbcMdc.newFixedThreadPool(
371+
String.format("BQ-Metadata-%s", connectionId), this.metadataFetchThreadCount);
374372
}
375373
}
376374

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

Lines changed: 66 additions & 393 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.google.cloud.bigquery.exception.BigQueryJdbcException;
2020
import com.google.cloud.bigquery.exception.BigQueryJdbcRuntimeException;
21+
import com.google.cloud.bigquery.jdbc.utils.BigQueryJdbcVersionUtility;
2122
import io.grpc.LoadBalancerRegistry;
2223
import io.grpc.internal.PickFirstLoadBalancerProvider;
2324
import java.io.IOException;
@@ -55,9 +56,6 @@ public class BigQueryDriver implements Driver {
5556

5657
private static final BigQueryJdbcCustomLogger LOG =
5758
new BigQueryJdbcCustomLogger(BigQueryDriver.class.getName());
58-
// TODO: update this when JDBC goes GA
59-
private static final int JDBC_MAJOR_VERSION = 0;
60-
private static final int JDBC_MINOR_VERSION = 1;
6159
static BigQueryDriver registeredBigqueryJdbcDriver;
6260

6361
static {
@@ -243,13 +241,13 @@ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
243241
@Override
244242
public int getMajorVersion() {
245243
LOG.finest("++enter++");
246-
return JDBC_MAJOR_VERSION;
244+
return BigQueryJdbcVersionUtility.getDriverMajorVersion();
247245
}
248246

249247
@Override
250248
public int getMinorVersion() {
251249
LOG.finest("++enter++");
252-
return JDBC_MINOR_VERSION;
250+
return BigQueryJdbcVersionUtility.getDriverMinorVersion();
253251
}
254252

255253
@Override

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,23 @@ static BigQueryJsonResultSet of(
109109
schema, totalRows, buffer, statement, false, null, -1, -1, ownedTasks, null, null);
110110
}
111111

112+
static BigQueryJsonResultSet of(
113+
Schema schema,
114+
long totalRows,
115+
BlockingQueue<BigQueryFieldValueListWrapper> buffer,
116+
BigQueryStatement statement,
117+
Future<?> ownedTask) {
118+
return of(schema, totalRows, buffer, statement, new Future<?>[] {ownedTask});
119+
}
120+
121+
static BigQueryJsonResultSet of(
122+
Schema schema,
123+
long totalRows,
124+
BlockingQueue<BigQueryFieldValueListWrapper> buffer,
125+
BigQueryStatement statement) {
126+
return of(schema, totalRows, buffer, statement, (Future<?>[]) null);
127+
}
128+
112129
BigQueryJsonResultSet() {
113130
super(null, null, null, false);
114131
totalRows = 0;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.bigquery.jdbc.utils;
18+
19+
import com.google.cloud.bigquery.jdbc.BigQueryJdbcCustomLogger;
20+
import java.io.InputStream;
21+
import java.util.Properties;
22+
23+
/** Utility class to load and parse the JDBC driver version from dependencies.properties. */
24+
public final class BigQueryJdbcVersionUtility {
25+
26+
private static final BigQueryJdbcCustomLogger LOG =
27+
new BigQueryJdbcCustomLogger(BigQueryJdbcVersionUtility.class.getName());
28+
29+
private static final String DRIVER_VERSION;
30+
private static final int DRIVER_MAJOR_VERSION;
31+
private static final int DRIVER_MINOR_VERSION;
32+
33+
static {
34+
String version = "0.0.0";
35+
int major = 0;
36+
int minor = 0;
37+
try (InputStream input =
38+
BigQueryJdbcVersionUtility.class.getResourceAsStream(
39+
"/com/google/cloud/bigquery/jdbc/dependencies.properties")) {
40+
if (input == null) {
41+
throw new IllegalArgumentException(
42+
"Could not find dependencies.properties. Driver version information is unavailable.");
43+
}
44+
45+
Properties props = new Properties();
46+
props.load(input);
47+
String versionString = props.getProperty("version.jdbc");
48+
if (versionString == null || versionString.trim().isEmpty()) {
49+
throw new IllegalArgumentException(
50+
"The property version.jdbc not found or empty in dependencies.properties.");
51+
}
52+
53+
version = versionString.trim();
54+
String[] parts = version.split("\\.");
55+
if (parts.length < 2) {
56+
throw new IllegalArgumentException("Unexpected version format: " + versionString);
57+
}
58+
major = Integer.parseInt(parts[0]);
59+
String minorPart = parts[1];
60+
String numericMinor = minorPart.replaceAll("[^0-9].*", "");
61+
if (!numericMinor.isEmpty()) {
62+
minor = Integer.parseInt(numericMinor);
63+
}
64+
} catch (Exception e) {
65+
LOG.severe(
66+
"Error reading dependencies.properties. Driver version information is unavailable. Error: "
67+
+ e.getMessage(),
68+
e);
69+
}
70+
DRIVER_VERSION = version;
71+
DRIVER_MAJOR_VERSION = major;
72+
DRIVER_MINOR_VERSION = minor;
73+
}
74+
75+
private BigQueryJdbcVersionUtility() {
76+
// Utility class, static methods only.
77+
}
78+
79+
public static String getDriverVersion() {
80+
return DRIVER_VERSION;
81+
}
82+
83+
public static int getDriverMajorVersion() {
84+
return DRIVER_MAJOR_VERSION;
85+
}
86+
87+
public static int getDriverMinorVersion() {
88+
return DRIVER_MINOR_VERSION;
89+
}
90+
}

0 commit comments

Comments
 (0)