From 9595dab89144cb13e812f4a277bb424d98c6591c Mon Sep 17 00:00:00 2001 From: Veronica Wasson <3992422+VeronicaWasson@users.noreply.github.com> Date: Mon, 14 Feb 2022 08:01:15 -0800 Subject: [PATCH] docs(tutorials): Add STRUCT column to tutorial (#1534) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(tutorials): Add STRUCT column to tutorial Add a STRUCT column to the JsonWriteDefaultStream tutorial * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Mike Wasson <3992422+MikeWasson@users.noreply.github.com> Co-authored-by: Owl Bot --- .../main/java/com/example/JsonWriterDefaultStream.java | 9 +++++++-- .../src/test/resources/TestData.json | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tutorials/JsonWriterDefaultStream/src/main/java/com/example/JsonWriterDefaultStream.java b/tutorials/JsonWriterDefaultStream/src/main/java/com/example/JsonWriterDefaultStream.java index 63c223cf3b..a0a01f82bb 100644 --- a/tutorials/JsonWriterDefaultStream/src/main/java/com/example/JsonWriterDefaultStream.java +++ b/tutorials/JsonWriterDefaultStream/src/main/java/com/example/JsonWriterDefaultStream.java @@ -20,6 +20,7 @@ import com.google.cloud.bigquery.BigQuery; import com.google.cloud.bigquery.BigQueryOptions; import com.google.cloud.bigquery.Field; +import com.google.cloud.bigquery.FieldList; import com.google.cloud.bigquery.Schema; import com.google.cloud.bigquery.StandardSQLTypeName; import com.google.cloud.bigquery.StandardTableDefinition; @@ -68,8 +69,12 @@ public static void createDestinationTable( Field.of("author", StandardSQLTypeName.STRING), Field.of("committer", StandardSQLTypeName.STRING), Field.of("commit_date", StandardSQLTypeName.DATETIME), - Field.of("subject", StandardSQLTypeName.STRING), - Field.of("message", StandardSQLTypeName.STRING), + Field.of( + "commit_msg", + StandardSQLTypeName.STRUCT, + FieldList.of( + Field.of("subject", StandardSQLTypeName.STRING), + Field.of("message", StandardSQLTypeName.STRING))), Field.of("repo_name", StandardSQLTypeName.STRING)); // Create a table that uses this schema. diff --git a/tutorials/JsonWriterDefaultStream/src/test/resources/TestData.json b/tutorials/JsonWriterDefaultStream/src/test/resources/TestData.json index a060639297..b36e9ba263 100644 --- a/tutorials/JsonWriterDefaultStream/src/test/resources/TestData.json +++ b/tutorials/JsonWriterDefaultStream/src/test/resources/TestData.json @@ -1,5 +1,5 @@ -{"commit":"0001","parent":["00001"],"author":"user1","committer":"GitHub","subject":"Commit 1","message":"This is a commit.\n\n","repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-07-23T20:28:01"} -{"commit":"0002","parent":["00002"],"author":"user1","committer":"GitHub","subject":"Commit 2","message":"This is a commit.\n\n","repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-12-05T16:05:16"} -{"commit":"0003","parent":["00003"],"author":"user1","committer":"GitHub","subject":"Commit 3","message":"This is a commit.\n\n","repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-03-21T16:59:23"} -{"commit":"0004","parent":["00004"],"author":"user1","committer":"GitHub","subject":"Commit 4","message":"This is a commit.\n\n","repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-01-11T01:31:39"} -{"commit":"0005","parent":["00005"],"author":"user1","committer":"GitHub","subject":"Commit 5","message":"This is a commit.\n\n","repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-07-31T19:09:09"} +{"commit":"0001","parent":["00001"],"author":"user1","committer":"GitHub","commit_msg":{"subject":"Commit 1","message":"This is a commit.\n\n"},"repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-07-23T20:28:01"} +{"commit":"0002","parent":["00002"],"author":"user1","committer":"GitHub","commit_msg":{"subject":"Commit 2","message":"This is a commit.\n\n"},"repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-12-05T16:05:16"} +{"commit":"0003","parent":["00003"],"author":"user1","committer":"GitHub","commit_msg":{"subject":"Commit 3","message":"This is a commit.\n\n"},"repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-03-21T16:59:23"} +{"commit":"0004","parent":["00004"],"author":"user1","committer":"GitHub","commit_msg":{"subject":"Commit 4","message":"This is a commit.\n\n"},"repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-01-11T01:31:39"} +{"commit":"0005","parent":["00005"],"author":"user1","committer":"GitHub","commit_msg":{"subject":"Commit 5","message":"This is a commit.\n\n"},"repo_name":"googleapis/java-bigquerystorage","commit_date":"2019-07-31T19:09:09"}