@@ -39,10 +39,12 @@ public static void main(String... args) throws Exception {
3939 // [START bigquery_simple_app_query]
4040 QueryJobConfiguration queryConfig =
4141 QueryJobConfiguration .newBuilder (
42- "SELECT commit, author, repo_name "
43- + "FROM `bigquery-public-data.github_repos.commits` "
44- + "WHERE subject like '%bigquery%' "
45- + "ORDER BY subject DESC LIMIT 10" )
42+ "SELECT CONCAT('https://stackoverflow.com/questions/', "
43+ + "CAST(id as STRING)) as url, view_count "
44+ + "FROM `bigquery-public-data.stackoverflow.posts_questions` "
45+ + "WHERE tags like '%google-bigquery%' "
46+ + "ORDER BY view_count DESC "
47+ + "LIMIT 10" )
4648 // Use standard SQL syntax for queries.
4749 // See: https://cloud.google.com/bigquery/sql-reference/
4850 .setUseLegacySql (false )
@@ -72,15 +74,9 @@ public static void main(String... args) throws Exception {
7274 // Print all pages of the results.
7375 for (FieldValueList row : result .iterateAll ()) {
7476 // String type
75- String commit = row .get ("commit" ).getStringValue ();
76- // Record type
77- FieldValueList author = row .get ("author" ).getRecordValue ();
78- String name = author .get ("name" ).getStringValue ();
79- String email = author .get ("email" ).getStringValue ();
80- // String Repeated type
81- String repoName = row .get ("repo_name" ).getRecordValue ().get (0 ).getStringValue ();
82- System .out .printf (
83- "Repo name: %s Author name: %s email: %s commit: %s\n " , repoName , name , email , commit );
77+ String url = row .get ("url" ).getStringValue ();
78+ String viewCount = row .get ("view_count" ).getStringValue ();
79+ System .out .printf ("%s : %s views\n " , url , viewCount );
8480 }
8581 // [END bigquery_simple_app_print]
8682 }
0 commit comments