Skip to content

Commit ec447b5

Browse files
diegomarquezplqiu96gemini-code-assist[bot]renovate-botblakeli0
authored
feat: update with latest from main (#4034)
* chore: sync with last release from main branch * feat: Introduce DataFormatOptions to configure the output of BigQuery data types (#4010) * feat: Create DataFormatOptions in BigQuery * feat: Add Builder class for DataFormatOptions * fix: Update existing references of useInt64Timestamp to use DataFormatOption's variant * chore: Fix lint issues * chore: Address PR feedback * chore: Add tests for useInt64Timestamp behavior * chore: Address failing tests and GCA * chore: Remove unused fromPb method * feat: Add timestamp_precision to Field (#4014) * feat: Add timestamp_precision to Field * Apply suggestion from @gemini-code-assist[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * chore: Address GCA PR feedback * chore: Fix typo * chore: Remove default value * chore: Address PR feedback --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * chore: Use custom timestamp validator for ISO8601 timestamps with more than nanosecond precision (#4017) * chore: Use custom timestamp validator for ISO8601 timestamps with more than nanosecond precision * chore: Rename helper method to validateTimestamp * chore: Address GCA comments * chore: Address last GCA comment * chore: Update to use assert helper method * test: Clean up resources created in ITs (#4024) * chore: Cleanup initialized resources * chore: Delete created dataset * chore: Use try-with to close stream * chore: Cleanup Intellij test warnings (#4026) * chore: Cleanup initialized resources * chore: Use try-with to close stream * chore: Cleanup Intellij test warnings * chore: Allow for floating point inaccuracies * chore: Add otel delete operation * deps: update actions/upload-artifact action to v6 (#4027) Co-authored-by: Blake Li <[email protected]> * chore: Use assertThrows in tests (#4028) * chore: Cleanup initialized resources * chore: Use try-with to close stream * chore: Cleanup Intellij test warnings * chore: Allow for floating point inaccuracies * chore: Add otel delete operation * chore: Clean up rest of the IT test file * chore: Add GCA feedback * chore: Update renovate.json (#4031) deps update from bigquerystorage was incorrectly marked as chore(deps). This would cause the upgrade not show up in the release notes and also not trigger release please. This is because the pattern /^com.google.cloud:google-cloud-bigquery is configured in renovate.json, which matches both bigquery and bigquerystorage. However, I believe the original intention is only for bigquery update in samples, not for bigquerystorage update. Fixing the pattern so that the String must ends with bigquery * chore(main): release 2.57.2-SNAPSHOT (#4032) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> * chore: fix unresolved conflicts --------- Co-authored-by: Lawrence Qiu <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mend Renovate <[email protected]> Co-authored-by: Blake Li <[email protected]> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
1 parent 580427d commit ec447b5

File tree

21 files changed

+752
-441
lines changed

21 files changed

+752
-441
lines changed

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
6060
# format to the repository Actions tab.
6161
- name: "Upload artifact"
62-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
62+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
6363
with:
6464
name: SARIF file
6565
path: results.sarif

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.56.0"
2+
".": "2.57.1"
33
}

benchmark/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>google-cloud-bigquery-parent</artifactId>
88
<groupId>com.google.cloud</groupId>
9-
<version>2.56.1-rc1-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
9+
<version>2.57.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
1010
</parent>
1111

1212
<properties>

google-cloud-bigquery-bom/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.google.cloud</groupId>
55
<artifactId>google-cloud-bigquery-bom</artifactId>
6-
<version>2.56.1-rc1-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
6+
<version>2.57.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
77
<packaging>pom</packaging>
88
<parent>
99
<groupId>com.google.cloud</groupId>
@@ -54,7 +54,7 @@
5454
<dependency>
5555
<groupId>com.google.cloud</groupId>
5656
<artifactId>google-cloud-bigquery</artifactId>
57-
<version>2.56.1-rc1-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
57+
<version>2.57.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
5858
</dependency>
5959
</dependencies>
6060
</dependencyManagement>

google-cloud-bigquery/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.google.cloud</groupId>
55
<artifactId>google-cloud-bigquery</artifactId>
6-
<version>2.56.1-rc1-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
6+
<version>2.57.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
77
<packaging>jar</packaging>
88
<name>BigQuery</name>
99
<url>https://github.com/googleapis/java-bigquery</url>
1010
<description>BigQuery</description>
1111
<parent>
1212
<groupId>com.google.cloud</groupId>
1313
<artifactId>google-cloud-bigquery-parent</artifactId>
14-
<version>2.56.1-rc1-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
14+
<version>2.57.2-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigquery:current} -->
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-bigquery</site.installationModule>

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,10 @@ public TableDataList call() throws IOException {
17311731
new PageImpl<>(
17321732
new TableDataPageFetcher(tableId, schema, serviceOptions, cursor, pageOptionMap),
17331733
cursor,
1734-
transformTableData(result.getRows(), schema, serviceOptions.getUseInt64Timestamps())),
1734+
transformTableData(
1735+
result.getRows(),
1736+
schema,
1737+
serviceOptions.getDataFormatOptions().useInt64Timestamp())),
17351738
result.getTotalRows());
17361739
} catch (BigQueryRetryHelperException e) {
17371740
throw BigQueryException.translateAndThrow(e);
@@ -2007,7 +2010,9 @@ public com.google.api.services.bigquery.model.QueryResponse call()
20072010
new QueryPageFetcher(jobId, schema, getOptions(), cursor, optionMap(options)),
20082011
cursor,
20092012
transformTableData(
2010-
results.getRows(), schema, getOptions().getUseInt64Timestamps())))
2013+
results.getRows(),
2014+
schema,
2015+
getOptions().getDataFormatOptions().useInt64Timestamp())))
20112016
.setJobId(jobId)
20122017
.setQueryId(results.getQueryId())
20132018
.build();
@@ -2021,7 +2026,9 @@ public com.google.api.services.bigquery.model.QueryResponse call()
20212026
new TableDataPageFetcher(null, schema, getOptions(), null, optionMap(options)),
20222027
null,
20232028
transformTableData(
2024-
results.getRows(), schema, getOptions().getUseInt64Timestamps())))
2029+
results.getRows(),
2030+
schema,
2031+
getOptions().getDataFormatOptions().useInt64Timestamp())))
20252032
// Return the JobID of the successful job
20262033
.setJobId(
20272034
results.getJobReference() != null ? JobId.fromPb(results.getJobReference()) : null)
@@ -2066,10 +2073,9 @@ && getOptions().getOpenTelemetryTracer() != null) {
20662073
}
20672074
try (Scope queryScope = querySpan != null ? querySpan.makeCurrent() : null) {
20682075
// If all parameters passed in configuration are supported by the query() method on the
2069-
// backend,
2070-
// put on fast path
2076+
// backend, put on fast path
20712077
QueryRequestInfo requestInfo =
2072-
new QueryRequestInfo(configuration, getOptions().getUseInt64Timestamps());
2078+
new QueryRequestInfo(configuration, getOptions().getDataFormatOptions());
20732079
if (requestInfo.isFastQuerySupported(jobId)) {
20742080
// Be careful when setting the projectID in JobId, if a projectID is specified in the JobId,
20752081
// the job created by the query method will use that project. This may cause the query to

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.cloud.bigquery;
1818

1919
import com.google.api.core.BetaApi;
20+
import com.google.api.core.ObsoleteApi;
2021
import com.google.api.gax.retrying.ResultRetryAlgorithm;
2122
import com.google.cloud.ServiceDefaults;
2223
import com.google.cloud.ServiceOptions;
@@ -26,6 +27,7 @@
2627
import com.google.cloud.bigquery.spi.BigQueryRpcFactory;
2728
import com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc;
2829
import com.google.cloud.http.HttpTransportOptions;
30+
import com.google.common.base.Preconditions;
2931
import com.google.common.collect.ImmutableSet;
3032
import io.opentelemetry.api.trace.Tracer;
3133
import java.util.Set;
@@ -41,6 +43,7 @@ public class BigQueryOptions extends ServiceOptions<BigQuery, BigQueryOptions> {
4143
// set the option ThrowNotFound when you want to throw the exception when the value not found
4244
private boolean setThrowNotFound;
4345
private boolean useInt64Timestamps;
46+
private DataFormatOptions dataFormatOptions;
4447
private JobCreationMode defaultJobCreationMode = JobCreationMode.JOB_CREATION_MODE_UNSPECIFIED;
4548
private boolean enableOpenTelemetryTracing;
4649
private Tracer openTelemetryTracer;
@@ -70,6 +73,7 @@ public static class Builder extends ServiceOptions.Builder<BigQuery, BigQueryOpt
7073

7174
private String location;
7275
private boolean useInt64Timestamps;
76+
private DataFormatOptions dataFormatOptions;
7377
private boolean enableOpenTelemetryTracing;
7478
private Tracer openTelemetryTracer;
7579
private ResultRetryAlgorithm<?> resultRetryAlgorithm;
@@ -94,11 +98,32 @@ public Builder setLocation(String location) {
9498
return this;
9599
}
96100

101+
/**
102+
* This setter is marked as Obsolete. Prefer {@link #setDataFormatOptions(DataFormatOptions)} to
103+
* set the int64timestamp configuration instead.
104+
*
105+
* <p>If useInt64Timestamps value is set in here and via DataFormatOptions, the
106+
* DataFormatOptions configuration value is used.
107+
*
108+
* <p>{@code DataFormatOptions.newBuilder().setUseInt64Timestamp(...).build()}
109+
*/
110+
@ObsoleteApi("Use setDataFormatOptions(DataFormatOptions) instead")
97111
public Builder setUseInt64Timestamps(boolean useInt64Timestamps) {
98112
this.useInt64Timestamps = useInt64Timestamps;
99113
return this;
100114
}
101115

116+
/**
117+
* Set the format options for the BigQuery data types
118+
*
119+
* @param dataFormatOptions Configuration of the formatting options
120+
*/
121+
public Builder setDataFormatOptions(DataFormatOptions dataFormatOptions) {
122+
Preconditions.checkNotNull(dataFormatOptions, "DataFormatOptions cannot be null");
123+
this.dataFormatOptions = dataFormatOptions;
124+
return this;
125+
}
126+
102127
/**
103128
* Enables OpenTelemetry tracing functionality for this BigQuery instance
104129
*
@@ -143,6 +168,15 @@ private BigQueryOptions(Builder builder) {
143168
} else {
144169
this.resultRetryAlgorithm = BigQueryBaseService.DEFAULT_BIGQUERY_EXCEPTION_HANDLER;
145170
}
171+
172+
// If dataFormatOptions is not set, then create a new instance and set it with the
173+
// useInt64Timestamps configured in BigQueryOptions
174+
if (builder.dataFormatOptions == null) {
175+
this.dataFormatOptions =
176+
DataFormatOptions.newBuilder().useInt64Timestamp(builder.useInt64Timestamps).build();
177+
} else {
178+
this.dataFormatOptions = builder.dataFormatOptions;
179+
}
146180
}
147181

148182
private static class BigQueryDefaults implements ServiceDefaults<BigQuery, BigQueryOptions> {
@@ -191,8 +225,23 @@ public void setThrowNotFound(boolean setThrowNotFound) {
191225
this.setThrowNotFound = setThrowNotFound;
192226
}
193227

228+
/**
229+
* This setter is marked as Obsolete. Prefer {@link
230+
* Builder#setDataFormatOptions(DataFormatOptions)} to set the int64timestamp configuration
231+
* instead.
232+
*
233+
* <p>If useInt64Timestamps is set via DataFormatOptions, then the value in DataFormatOptions will
234+
* be used. Otherwise, this value will be passed to DataFormatOptions.
235+
*
236+
* <p>Alternative: {@code DataFormatOptions.newBuilder().setUseInt64Timestamp(...).build()}
237+
*/
238+
@ObsoleteApi("Use Builder#setDataFormatOptions(DataFormatOptions) instead")
194239
public void setUseInt64Timestamps(boolean useInt64Timestamps) {
195240
this.useInt64Timestamps = useInt64Timestamps;
241+
// Because this setter exists outside the Builder, DataFormatOptions needs be rebuilt to
242+
// account for this setting.
243+
this.dataFormatOptions =
244+
dataFormatOptions.toBuilder().useInt64Timestamp(useInt64Timestamps).build();
196245
}
197246

198247
@Deprecated
@@ -206,8 +255,22 @@ public boolean getThrowNotFound() {
206255
return setThrowNotFound;
207256
}
208257

258+
/**
259+
* This getter is marked as Obsolete. Prefer {@link
260+
* DataFormatOptions.Builder#useInt64Timestamp(boolean)} to set the int64timestamp configuration
261+
* instead.
262+
*
263+
* <p>Warning: DataFormatOptions values have precedence. Use {@link
264+
* DataFormatOptions#useInt64Timestamp()} to get `useInt64Timestamp` value used by the BigQuery
265+
* client.
266+
*/
267+
@ObsoleteApi("Use getDataFormatOptions().isUseInt64Timestamp() instead")
209268
public boolean getUseInt64Timestamps() {
210-
return useInt64Timestamps;
269+
return dataFormatOptions.useInt64Timestamp();
270+
}
271+
272+
public DataFormatOptions getDataFormatOptions() {
273+
return dataFormatOptions;
211274
}
212275

213276
public JobCreationMode getDefaultJobCreationMode() {
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2025 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+
package com.google.cloud.bigquery;
17+
18+
import com.google.auto.value.AutoValue;
19+
import java.io.Serializable;
20+
21+
/**
22+
* Google BigQuery DataFormatOptions. Configures the output format for data types returned from
23+
* BigQuery.
24+
*/
25+
@AutoValue
26+
public abstract class DataFormatOptions implements Serializable {
27+
public enum TimestampFormatOptions {
28+
TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED("TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED"),
29+
FLOAT64("FLOAT64"),
30+
INT64("INT64"),
31+
ISO8601_STRING("ISO8601_STRING");
32+
33+
private final String format;
34+
35+
TimestampFormatOptions(String format) {
36+
this.format = format;
37+
}
38+
39+
@Override
40+
public String toString() {
41+
return format;
42+
}
43+
}
44+
45+
public abstract boolean useInt64Timestamp();
46+
47+
public abstract TimestampFormatOptions timestampFormatOptions();
48+
49+
public static Builder newBuilder() {
50+
return new AutoValue_DataFormatOptions.Builder()
51+
.useInt64Timestamp(false)
52+
.timestampFormatOptions(TimestampFormatOptions.TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED);
53+
}
54+
55+
public abstract Builder toBuilder();
56+
57+
@AutoValue.Builder
58+
public abstract static class Builder {
59+
public abstract Builder useInt64Timestamp(boolean useInt64Timestamp);
60+
61+
public abstract Builder timestampFormatOptions(TimestampFormatOptions timestampFormatOptions);
62+
63+
public abstract DataFormatOptions build();
64+
}
65+
66+
com.google.api.services.bigquery.model.DataFormatOptions toPb() {
67+
com.google.api.services.bigquery.model.DataFormatOptions request =
68+
new com.google.api.services.bigquery.model.DataFormatOptions();
69+
request.setUseInt64Timestamp(useInt64Timestamp());
70+
request.setTimestampOutputFormat(timestampFormatOptions().toString());
71+
return request;
72+
}
73+
}

0 commit comments

Comments
 (0)