File tree Expand file tree Collapse file tree
java-bigquery/samples/snippets/src
main/java/com/example/bigquery
test/java/com/example/bigquery Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,8 +29,12 @@ public class SimpleQuery {
2929 public static void main (String [] args ) {
3030 // TODO(developer): Replace this query before running the sample.
3131 String query =
32- "SELECT corpus, count(*) as corpus_count "
33- + "FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;" ;
32+ "SELECT name, SUM(number) as total_people "
33+ + "FROM `bigquery-public-data.usa_names.usa_1910_2013` "
34+ + "WHERE state = 'TX' "
35+ + "GROUP BY name, state "
36+ + "ORDER BY total_people DESC "
37+ + "LIMIT 100;" ;
3438 simpleQuery (query );
3539 }
3640
@@ -51,8 +55,8 @@ public static void simpleQuery(String query) {
5155 .iterateAll ()
5256 .forEach (
5357 row -> {
54- System .out .print ("corpus :" + row .get ("corpus " ).getStringValue ());
55- System .out .print (", count:" + row .get ("corpus_count " ).getLongValue ());
58+ System .out .print ("name :" + row .get ("name " ).getStringValue ());
59+ System .out .print (", count:" + row .get ("total_people " ).getLongValue ());
5660 System .out .println ();
5761 });
5862
Original file line number Diff line number Diff line change @@ -52,8 +52,12 @@ public void tearDown() {
5252 @ Test
5353 public void testSimpleQuery () {
5454 String query =
55- "SELECT corpus, count(*) as corpus_count "
56- + "FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;" ;
55+ "SELECT name, SUM(number) as total_people "
56+ + "FROM `bigquery-public-data.usa_names.usa_1910_2013` "
57+ + "WHERE state = 'TX' "
58+ + "GROUP BY name, state "
59+ + "ORDER BY total_people DESC "
60+ + "LIMIT 100;" ;
5761
5862 SimpleQuery .simpleQuery (query );
5963 assertThat (bout .toString ()).contains ("Query ran successfully" );
You can’t perform that action at this time.
0 commit comments