Skip to content

Commit ebedcc0

Browse files
authored
feat: add sample code about default missingValueInterpretation (#2249)
* feat: add sample code about default missingValueInterpretation * .
1 parent 8302029 commit ebedcc0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.cloud.bigquery.BigQueryOptions;
2727
import com.google.cloud.bigquery.QueryJobConfiguration;
2828
import com.google.cloud.bigquery.TableResult;
29+
import com.google.cloud.bigquery.storage.v1.AppendRowsRequest;
2930
import com.google.cloud.bigquery.storage.v1.AppendRowsResponse;
3031
import com.google.cloud.bigquery.storage.v1.BigQueryWriteClient;
3132
import com.google.cloud.bigquery.storage.v1.BigQueryWriteSettings;
@@ -178,6 +179,10 @@ public void initialize(TableName parentTable)
178179
.setChannelsPerCpu(2)
179180
.build())
180181
.setEnableConnectionPool(true)
182+
// If value is missing in json and there is a default value configured on bigquery
183+
// column, apply the default value to the missing value field.
184+
.setDefaultMissingValueInterpretation(
185+
AppendRowsRequest.MissingValueInterpretation.DEFAULT_VALUE)
181186
.build();
182187
}
183188

0 commit comments

Comments
 (0)