tree: 3c3810d631c42372a02a32f83dfcb2d53b717093 [path history] [tgz]
  1. benchmarks/
  2. connection/
  3. datatransfer/
  4. internal/
  5. migration/
  6. reservation/
  7. storage/
  8. bigquery.go
  9. bigquery.replay
  10. bigquery_test.go
  11. CHANGES.md
  12. copy.go
  13. copy_test.go
  14. dataset.go
  15. dataset_test.go
  16. doc.go
  17. error.go
  18. error_test.go
  19. examples_test.go
  20. external.go
  21. external_test.go
  22. extract.go
  23. extract_test.go
  24. file.go
  25. file_test.go
  26. gcs.go
  27. go.mod
  28. go.sum
  29. go_mod_tidy_hack.go
  30. iam.go
  31. iam_test.go
  32. inserter.go
  33. inserter_test.go
  34. integration_test.go
  35. iterator.go
  36. iterator_test.go
  37. job.go
  38. job_test.go
  39. load.go
  40. load_test.go
  41. model.go
  42. model_test.go
  43. nulls.go
  44. nulls_test.go
  45. oc_test.go
  46. params.go
  47. params_test.go
  48. query.go
  49. query_test.go
  50. random.go
  51. read_test.go
  52. README.md
  53. routine.go
  54. routine_test.go
  55. schema.go
  56. schema_test.go
  57. standardsql.go
  58. standardsql_test.go
  59. table.go
  60. table_test.go
  61. value.go
  62. value_test.go
bigquery/README.md

BigQuery Go Reference

Example Usage

First create a bigquery.Client to use throughout your application: [snip]:# (bq-1)

c, err := bigquery.NewClient(ctx, "my-project-ID")
if err != nil {
	// TODO: Handle error.
}

Then use that client to interact with the API: [snip]:# (bq-2)

// Construct a query.
q := c.Query(`
    SELECT year, SUM(number)
    FROM [bigquery-public-data:usa_names.usa_1910_2013]
    WHERE name = "William"
    GROUP BY year
    ORDER BY year
`)
// Execute the query.
it, err := q.Read(ctx)
if err != nil {
	// TODO: Handle error.
}
// Iterate through the results.
for {
	var values []bigquery.Value
	err := it.Next(&values)
	if err == iterator.Done {  // from "google.golang.org/api/iterator"
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	fmt.Println(values)
}