Skip to content

Commit

Permalink
docs(bigquery): update package docs to show query parameterization (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
shollyman authored Nov 1, 2023
1 parent 2ba47cb commit cc76ab3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bigquery/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ To start working with this package, create a client:
# Querying
To query existing tables, create a Query and call its Read method:
To query existing tables, create a Query and call its Read method, which starts the
query and waits for it to complete:
q := client.Query(`
SELECT year, SUM(number) as num
FROM ` + "`bigquery-public-data.usa_names.usa_1910_2013`" + `
WHERE name = "William"
FROM bigquery-public-data.usa_names.usa_1910_2013
WHERE name = @name
GROUP BY year
ORDER BY year
`)
q.Parameters = []bigquery.QueryParameter{
{Name: "name", Value: "William"},
}
it, err := q.Read(ctx)
if err != nil {
// TODO: Handle error.
Expand Down

0 comments on commit cc76ab3

Please sign in to comment.