Skip to content

Commit cbefd64

Browse files
committed
chore: update simple query sample to use stardarized query on other technologies
1 parent c6532ac commit cbefd64

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

java-bigquery/samples/snippets/src/main/java/com/example/bigquery/SimpleQuery.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff 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

java-bigquery/samples/snippets/src/test/java/com/example/bigquery/SimpleQueryIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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");

0 commit comments

Comments
 (0)