TheGoogle.Cloud.BigQuery.V2package wraps a lot of the functionality of
the underlying REST API. This document lays out the patterns
involved to help guide further API extensions.
BigQueryClient
Like other REST API wrappers,BigQueryClientis the entry point for
everything. This is an abstract class (to allow for mocking) withCreate/CreateAsyncstatic methods which construct instances ofBigQueryClientImpl. The implementation can be constructed directly
if necessary, e.g. for constructor-based dependency injection.
Methods which need to interact with the service should be declared
and documented inBigQueryClient, as virtual methods which throwNotImplementedException. They are then implemented inBigQueryClientImpl.
The canonical way of identifying any of the entities is via areference,
e.g.DatasetReference,JobReference,TableReference,ProjectReference. It is easy to construct a reference either manually or viaBigQueryClientor a parent entity (e.g.BigQueryDataset.GetTableReference).
Any operation onBigQueryClientmustat leasthave a
canonical form accepting a suitable reference. Itmayalso have
other overloads to retrieve entities via just component IDs. The
overloads must be virtual to support simple mocking, but should not
be overridden in the implementation. The documentation must be clear
that the overloads simply delegate to the canonical form using a*Referenceconstructed with aGet*Referencemethod.
TheGet*Referencemethods inBigQueryClientare not virtual;
they are not a point of interaction with the service and so do not
require faking for test purposes.
BigQueryClientrequires a project ID to be specified, as almost
all BigQuery operations require a project ID, and almost all
operations will use the same one. The project ID is typically used
as an invisible default, but it is still possible to query a
dataset/table/job in a different project.
Options
All operations accept at least one "options" parameter (and sometimes more, if
the operation is a shortcut for multiple operations). All properties on options
classes are nullable, with null being the default value, indicating that the user
hasn't specified that option.
Datasets, tables and results
All the relevant operations are available onBigQueryClient, but
many are more conveniently placed on other classes representing
entities:
BigQueryDataset: a dataset containing tables
BigQueryTable: a table
BigQueryJob: a job, which may or may not be completed
Additionally,BigQueryResultsrepresents the results of a completed query in a form
which is easy to iterate over and obtain "pages" of results.
TheBigQueryprefix here avoids confusion with the underlying
REST-based resources, which are still available.
Synchronous vs asynchronous C# calls
All API calls potentially involving server interaction come in sync
and async flavours.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eGoogle.Cloud.BigQuery.V2\u003c/code\u003e package is 3.11.0, with previous versions ranging from 3.10.0 down to 2.2.0 also available, all of which are documented via distinct links.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBigQueryClient\u003c/code\u003e is the central entry point for interacting with the BigQuery service, featuring methods for service interaction that are declared as virtual and implemented in \u003ccode\u003eBigQueryClientImpl\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEntities within the BigQuery API are identified via references like \u003ccode\u003eDatasetReference\u003c/code\u003e, \u003ccode\u003eJobReference\u003c/code\u003e, and \u003ccode\u003eTableReference\u003c/code\u003e, which can be constructed manually, through \u003ccode\u003eBigQueryClient\u003c/code\u003e, or via a parent entity.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBigQueryClient\u003c/code\u003e class requires a project ID, and this ID acts as an invisible default, though operations in different projects are still supported.\u003c/p\u003e\n"],["\u003cp\u003eAPI calls involving server interaction are available in both synchronous and asynchronous forms for C# operations.\u003c/p\u003e\n"]]],[],null,["Version latestkeyboard_arrow_down\n\n- [3.11.0 (latest)](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/design)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.10.0/design)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.9.0/design)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.8.0/design)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.7.0/design)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.6.0/design)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.5.0/design)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.4.0/design)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.3.0/design)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.2.0/design)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.1.0/design)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/3.0.0/design)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/2.4.0/design)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/2.3.0/design)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.BigQuery.V2/2.2.0/design) \n\nBigQuery API design\n===================\n\nThe `Google.Cloud.BigQuery.V2` package wraps a lot of the functionality of\nthe underlying REST API. This document lays out the patterns\ninvolved to help guide further API extensions.\n\n`BigQueryClient`\n----------------\n\nLike other REST API wrappers, `BigQueryClient` is the entry point for\neverything. This is an abstract class (to allow for mocking) with\n`Create`/`CreateAsync` static methods which construct instances of\n`BigQueryClientImpl`. The implementation can be constructed directly\nif necessary, e.g. for constructor-based dependency injection.\n\nMethods which need to interact with the service should be declared\nand documented in `BigQueryClient`, as virtual methods which throw\n`NotImplementedException`. They are then implemented in\n`BigQueryClientImpl`.\n\nThe canonical way of identifying any of the entities is via a *reference* ,\ne.g. `DatasetReference`, `JobReference`, `TableReference`,\n`ProjectReference`. It is easy to construct a reference either manually or via\n`BigQueryClient` or a parent entity (e.g.\n`BigQueryDataset.GetTableReference`).\n\nAny operation on `BigQueryClient` must *at least* have a\ncanonical form accepting a suitable reference. It *may* also have\nother overloads to retrieve entities via just component IDs. The\noverloads must be virtual to support simple mocking, but should not\nbe overridden in the implementation. The documentation must be clear\nthat the overloads simply delegate to the canonical form using a\n`*Reference` constructed with a `Get*Reference` method.\n\nThe `Get*Reference` methods in `BigQueryClient` are not virtual;\nthey are not a point of interaction with the service and so do not\nrequire faking for test purposes.\n\n`BigQueryClient` requires a project ID to be specified, as almost\nall BigQuery operations require a project ID, and almost all\noperations will use the same one. The project ID is typically used\nas an invisible default, but it is still possible to query a\ndataset/table/job in a different project.\n\nOptions\n-------\n\nAll operations accept at least one \"options\" parameter (and sometimes more, if\nthe operation is a shortcut for multiple operations). All properties on options\nclasses are nullable, with null being the default value, indicating that the user\nhasn't specified that option.\n\nDatasets, tables and results\n----------------------------\n\nAll the relevant operations are available on `BigQueryClient`, but\nmany are more conveniently placed on other classes representing\nentities:\n\n- `BigQueryDataset`: a dataset containing tables\n- `BigQueryTable`: a table\n- `BigQueryJob`: a job, which may or may not be completed\n\nAdditionally, `BigQueryResults` represents the results of a completed query in a form\nwhich is easy to iterate over and obtain \"pages\" of results.\n\nThe `BigQuery` prefix here avoids confusion with the underlying\nREST-based resources, which are still available.\n\nSynchronous vs asynchronous C# calls\n------------------------------------\n\nAll API calls potentially involving server interaction come in sync\nand async flavours."]]