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