Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update samples snippet to write to BYTES instead of ARRAY<BYTES> #2876

Merged
merged 2 commits into from Sep 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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