Skip to content

Commit

Permalink
fix: update samples snippet to write to BYTES instead of ARRAY<BYTES> (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
forksumit and gcf-owl-bot[bot] committed Sep 21, 2023
1 parent 8644252 commit 7e040e9
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -30,6 +30,7 @@
import com.google.cloud.bigquery.TableDefinition;
import com.google.cloud.bigquery.TableId;
import com.google.cloud.bigquery.TableInfo;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -53,10 +54,7 @@ public static void insertingDataTypes(String datasetName, String tableName) {
// Inserting data types
Field name = Field.of("name", StandardSQLTypeName.STRING);
Field age = Field.of("age", StandardSQLTypeName.INT64);
Field school =
Field.newBuilder("school", StandardSQLTypeName.BYTES)
.setMode(Field.Mode.REPEATED)
.build();
Field school = Field.of("school", StandardSQLTypeName.BYTES);
Field location = Field.of("location", StandardSQLTypeName.GEOGRAPHY);
Field measurements =
Field.newBuilder("measurements", StandardSQLTypeName.FLOAT64)
Expand Down Expand Up @@ -86,7 +84,7 @@ public static void insertingDataTypes(String datasetName, String tableName) {
Map<String, Object> rowContent = new HashMap<>();
rowContent.put("name", "Tom");
rowContent.put("age", 30);
rowContent.put("school", "Test University".getBytes());
rowContent.put("school", Base64.getEncoder().encodeToString("Test University".getBytes()));
rowContent.put("location", "POINT(1 2)");
rowContent.put("measurements", new Float[] {50.05f, 100.5f});
rowContent.put("datesTime", datesTimeContent);
Expand Down

0 comments on commit 7e040e9

Please sign in to comment.