Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit 21e399b

Browse files
authored
fix: remove schema update capability from jsonwriter and delete related tests (#1047)
* fix: remove schema update capability from json writer and delete related tests * . * .
1 parent e75f9e7 commit 21e399b

4 files changed

Lines changed: 5 additions & 700 deletions

File tree

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/JsonStreamWriter.java

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@
3636
/**
3737
* A StreamWriter that can write JSON data (JSONObjects) to BigQuery tables. The JsonStreamWriter is
3838
* built on top of a StreamWriter, and it simply converts all JSON data to protobuf messages then
39-
* calls StreamWriter's append() method to write to BigQuery tables. It maintains all StreamWriter
40-
* functions, but also provides an additional feature: schema update support, where if the BigQuery
41-
* table schema is updated, users will be able to ingest data on the new schema after some time (in
42-
* order of minutes).
39+
* calls StreamWriter's append() method to write to BigQuery tables.
4340
*/
4441
public class JsonStreamWriter implements AutoCloseable {
4542
private static String streamPatternString =
@@ -83,8 +80,7 @@ private JsonStreamWriter(Builder builder)
8380

8481
/**
8582
* Writes a JSONArray that contains JSONObjects to the BigQuery table by first converting the JSON
86-
* data to protobuf messages, then using StreamWriter's append() to write the data. If there is a
87-
* schema update, the OnSchemaUpdateRunnable will be used to determine what actions to perform.
83+
* data to protobuf messages, then using StreamWriter's append() to write the data.
8884
*
8985
* @param jsonArr The JSON array that contains JSONObjects to be written
9086
* @return ApiFuture<AppendRowsResponse> returns an AppendRowsResponse message wrapped in an
@@ -96,8 +92,7 @@ public ApiFuture<AppendRowsResponse> append(JSONArray jsonArr) {
9692

9793
/**
9894
* Writes a JSONArray that contains JSONObjects to the BigQuery table by first converting the JSON
99-
* data to protobuf messages, then using StreamWriter's append() to write the data. If there is a
100-
* schema update, the OnSchemaUpdateRunnable will be used to determine what actions to perform.
95+
* data to protobuf messages, then using StreamWriter's append() to write the data.
10196
*
10297
* @param jsonArr The JSON array that contains JSONObjects to be written
10398
* @param offset Offset for deduplication
@@ -193,10 +188,6 @@ private void setStreamWriterSettings(
193188
if (createDefaultStream) {
194189
streamWriterBuilder.createDefaultStream();
195190
}
196-
JsonStreamWriterOnSchemaUpdateRunnable jsonStreamWriterOnSchemaUpdateRunnable =
197-
new JsonStreamWriterOnSchemaUpdateRunnable();
198-
jsonStreamWriterOnSchemaUpdateRunnable.setJsonStreamWriter(this);
199-
streamWriterBuilder.setOnSchemaUpdateRunnable(jsonStreamWriterOnSchemaUpdateRunnable);
200191
}
201192

202193
/**
@@ -267,39 +258,6 @@ public void close() {
267258
this.streamWriter.close();
268259
}
269260

270-
private class JsonStreamWriterOnSchemaUpdateRunnable extends OnSchemaUpdateRunnable {
271-
private JsonStreamWriter jsonStreamWriter;
272-
/**
273-
* Setter for the jsonStreamWriter
274-
*
275-
* @param jsonStreamWriter
276-
*/
277-
public void setJsonStreamWriter(JsonStreamWriter jsonStreamWriter) {
278-
this.jsonStreamWriter = jsonStreamWriter;
279-
}
280-
281-
/** Getter for the jsonStreamWriter */
282-
public JsonStreamWriter getJsonStreamWriter() {
283-
return this.jsonStreamWriter;
284-
}
285-
286-
@Override
287-
public void run() {
288-
this.getJsonStreamWriter().setTableSchema(this.getUpdatedSchema());
289-
try {
290-
this.getJsonStreamWriter().refreshConnection();
291-
} catch (InterruptedException | IOException e) {
292-
LOG.severe("StreamWriter failed to refresh upon schema update." + e);
293-
return;
294-
} catch (Descriptors.DescriptorValidationException e) {
295-
LOG.severe(
296-
"Schema update fail: updated schema could not be converted to a valid descriptor.");
297-
return;
298-
}
299-
LOG.info("Successfully updated schema: " + this.getUpdatedSchema());
300-
}
301-
}
302-
303261
public static final class Builder {
304262
private String streamOrTableName;
305263
private BigQueryWriteClient client;

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1beta2/OnSchemaUpdateRunnable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* A abstract class that implements the Runnable interface and provides access to the current
2020
* StreamWriter and updatedSchema. This runnable will only be called when a updated schema has been
2121
* passed back through the AppendRowsResponse. Users should only implement the run() function.
22+
*
23+
* @deprecated
2224
*/
2325
public abstract class OnSchemaUpdateRunnable implements Runnable {
2426
private StreamWriter streamWriter;

0 commit comments

Comments
 (0)