Skip to content

Commit cc76ab3

Browse files
authored
docs(bigquery): update package docs to show query parameterization (#8965)
Improve discoverability of parameterization by making it part of the package level docs. We also cleanup the backtick in the table reference as BQ no longer requires literal escaping for project identifiers.
1 parent 2ba47cb commit cc76ab3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bigquery/doc.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ To start working with this package, create a client:
3333
3434
# Querying
3535
36-
To query existing tables, create a Query and call its Read method:
36+
To query existing tables, create a Query and call its Read method, which starts the
37+
query and waits for it to complete:
3738
3839
q := client.Query(`
3940
SELECT year, SUM(number) as num
40-
FROM ` + "`bigquery-public-data.usa_names.usa_1910_2013`" + `
41-
WHERE name = "William"
41+
FROM bigquery-public-data.usa_names.usa_1910_2013
42+
WHERE name = @name
4243
GROUP BY year
4344
ORDER BY year
4445
`)
46+
q.Parameters = []bigquery.QueryParameter{
47+
{Name: "name", Value: "William"},
48+
}
4549
it, err := q.Read(ctx)
4650
if err != nil {
4751
// TODO: Handle error.

0 commit comments

Comments
 (0)