Skip to content

Commit 7e040e9

Browse files
fix: update samples snippet to write to BYTES instead of ARRAY<BYTES> (#2876)
* fix: update snippet to write to BYTES instead of ARRAY<BYTES> * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8644252 commit 7e040e9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

samples/snippets/src/main/java/com/example/bigquery/InsertingDataTypes.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.google.cloud.bigquery.TableDefinition;
3131
import com.google.cloud.bigquery.TableId;
3232
import com.google.cloud.bigquery.TableInfo;
33+
import java.util.Base64;
3334
import java.util.HashMap;
3435
import java.util.List;
3536
import java.util.Map;
@@ -53,10 +54,7 @@ public static void insertingDataTypes(String datasetName, String tableName) {
5354
// Inserting data types
5455
Field name = Field.of("name", StandardSQLTypeName.STRING);
5556
Field age = Field.of("age", StandardSQLTypeName.INT64);
56-
Field school =
57-
Field.newBuilder("school", StandardSQLTypeName.BYTES)
58-
.setMode(Field.Mode.REPEATED)
59-
.build();
57+
Field school = Field.of("school", StandardSQLTypeName.BYTES);
6058
Field location = Field.of("location", StandardSQLTypeName.GEOGRAPHY);
6159
Field measurements =
6260
Field.newBuilder("measurements", StandardSQLTypeName.FLOAT64)
@@ -86,7 +84,7 @@ public static void insertingDataTypes(String datasetName, String tableName) {
8684
Map<String, Object> rowContent = new HashMap<>();
8785
rowContent.put("name", "Tom");
8886
rowContent.put("age", 30);
89-
rowContent.put("school", "Test University".getBytes());
87+
rowContent.put("school", Base64.getEncoder().encodeToString("Test University".getBytes()));
9088
rowContent.put("location", "POINT(1 2)");
9189
rowContent.put("measurements", new Float[] {50.05f, 100.5f});
9290
rowContent.put("datesTime", datesTimeContent);

0 commit comments

Comments
 (0)