Google BigQuery v2 API - Class BigQueryClientImpl (3.4.0)

public sealed class BigQueryClientImpl : BigQueryClient, IDisposable

Reference documentation and code samples for the Google BigQuery v2 API class BigQueryClientImpl.

Wrapper around BigqueryService to provide simpler operations.

Inheritance

object > BigQueryClient > BigQueryClientImpl

Implements

IDisposable

Namespace

Google.Cloud.BigQuery.V2

Assembly

Google.Cloud.BigQuery.V2.dll

Remarks

This is the "default" implementation of BigQueryClient. Most client code should refer to BigQueryClient, creating instances with Create(string, GoogleCredential) and CreateAsync(string, GoogleCredential). The constructor of this class is public for the sake of constructor-based dependency injection.

Constructors

BigQueryClientImpl(ProjectReference, BigqueryService)

public BigQueryClientImpl(ProjectReference projectReference, BigqueryService service)

Constructs a new client wrapping the given BigqueryService.

Parameters
NameDescription
projectReferenceProjectReference

A fully-qualified identifier for the project. Must not be null.

serviceBigqueryService

The service to wrap. Must not be null.

Remarks

Care should be taken when constructing the service: if the default serializer settings are used, result values which can be parsed as date/time values can cause problems. Where possible, either use Create(string, GoogleCredential) or construct a service using serializer settings from CreateJsonSerializersSettings().

BigQueryClientImpl(ProjectReference, BigqueryService, string)

public BigQueryClientImpl(ProjectReference projectReference, BigqueryService service, string defaultLocation)

Constructs a new client wrapping the given BigqueryService, with a specified default location for location-specific operations.

Parameters
NameDescription
projectReferenceProjectReference

A fully-qualified identifier for the project. Must not be null.

serviceBigqueryService

The service to wrap. Must not be null.

defaultLocationstring

The default location to use for location-specific operations. May be null.

Remarks

Care should be taken when constructing the service: if the default serializer settings are used, result values which can be parsed as date/time values can cause problems. Where possible, either use Create(string, GoogleCredential) or construct a service using serializer settings from CreateJsonSerializersSettings().

BigQueryClientImpl(string, BigqueryService)

public BigQueryClientImpl(string projectId, BigqueryService service)

Constructs a new client wrapping the given BigqueryService, with no default location.

Parameters
NameDescription
projectIdstring

The ID of the project to work with. Must not be null.

serviceBigqueryService

The service to wrap. Must not be null.

Remarks

Care should be taken when constructing the service: if the default serializer settings are used, result values which can be parsed as date/time values can cause problems. Where possible, either use Create(string, GoogleCredential) or construct a service using serializer settings from CreateJsonSerializersSettings().

BigQueryClientImpl(string, BigqueryService, string)

public BigQueryClientImpl(string projectId, BigqueryService service, string defaultLocation)

Constructs a new client wrapping the given BigqueryService, with a specified default location for location-specific operations.

Parameters
NameDescription
projectIdstring

The ID of the project to work with. Must not be null.

serviceBigqueryService

The service to wrap. Must not be null.

defaultLocationstring

The default location to use for location-specific operations. May be null.

Remarks

Care should be taken when constructing the service: if the default serializer settings are used, result values which can be parsed as date/time values can cause problems. Where possible, either use Create(string, GoogleCredential) or construct a service using serializer settings from CreateJsonSerializersSettings().

Properties

ApplicationName

public static string ApplicationName { get; set; }

The default application name used when creating a BigqueryService. Defaults to "google-cloud-dotnet"; must not be null.

Property Value
TypeDescription
string
Remarks

Most applications will never want to set this, which is why it's in this class rather than BigQueryClient.

DefaultLocation

public override string DefaultLocation { get; }

The default location to use for all operations where locations can be specified, such as dataset and job creation.

Property Value
TypeDescription
string
Overrides

PrettyPrint

public override bool PrettyPrint { get; }

Determines whether or not responses should be formatted with whitespace for readability.

Property Value
TypeDescription
bool
Overrides

ProjectId

public override string ProjectId { get; }

The ID of the project this client operates on. All operations that require a project to be specified implicitly supply this ID.

Property Value
TypeDescription
string
Overrides

Service

public override BigqueryService Service { get; }

The underlying BigQuery service object used by this client.

Property Value
TypeDescription
BigqueryService
Overrides Remarks

The BigQueryClient class only provides convenience operations built on top of an existing service object. Any more complex operations which are not supported by this wrapper may wish to use the same service object as the wrapper, in order to take advantage of its configuration (for authentication, application naming etc).

Methods

CancelJob(JobReference, CancelJobOptions)

public override BigQueryJob CancelJob(JobReference jobReference, CancelJobOptions options = null)

Cancels the specified job.

Parameters
NameDescription
jobReferenceJobReference

A fully-qualified identifier for the job. Must not be null.

optionsCancelJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryJob

The final state of the job.

Overrides

CancelJobAsync(JobReference, CancelJobOptions, CancellationToken)

public override Task<BigQueryJob> CancelJobAsync(JobReference jobReference, CancelJobOptions options = null, CancellationToken cancellationToken = default)

Asynchronously cancels the specified job.

Parameters
NameDescription
jobReferenceJobReference

A fully-qualified identifier for the job. Must not be null.

optionsCancelJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskBigQueryJob

A task representing the asynchronous operation. When complete, the result is the final state of the job.

Overrides

ClearDatasetLabels(DatasetReference, ModifyLabelsOptions)

public override IDictionary<string, string> ClearDatasetLabels(DatasetReference datasetReference, ModifyLabelsOptions options = null)

Clears all labels on the specified dataset.

Parameters
NameDescription
datasetReferenceDatasetReference

A fully-qualified identifier for the dataset. Must not be null.

optionsModifyLabelsOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
IDictionarystringstring

A dictionary with the labels on the dataset before they were cleared.

Overrides

ClearDatasetLabelsAsync(DatasetReference, ModifyLabelsOptions, CancellationToken)

public override Task<IDictionary<string, string>> ClearDatasetLabelsAsync(DatasetReference datasetReference, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default)

Asynchronously clears all labels on the specified dataset.

Parameters
NameDescription
datasetReferenceDatasetReference

A fully-qualified identifier for the dataset. Must not be null.

optionsModifyLabelsOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskIDictionarystringstring

A task representing the asynchronous operation. When complete, the result is a dictionary with the labels on the dataset before they were cleared.

Overrides

CreateCopyJob(IEnumerable<TableReference>, TableReference, CreateCopyJobOptions)

public override BigQueryJob CreateCopyJob(IEnumerable<TableReference> sources, TableReference destination, CreateCopyJobOptions options = null)

Creates a job to copy data from at least one table to another.

Parameters
NameDescription
sourcesIEnumerableTableReference

The source tables to copy. Must not be null or empty.

destinationTableReference

The destination to copy to. Must not be null.

optionsCreateCopyJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryJob

The job created for the copy operation.

Overrides Remarks

To avoid confusion between source and destination tables, overloads are not provided that take the individual components of table references. Instead, use GetTableReference(string, string) or GetTableReference(string, string, string) to create table references.

CreateCopyJobAsync(IEnumerable<TableReference>, TableReference, CreateCopyJobOptions, CancellationToken)

public override Task<BigQueryJob> CreateCopyJobAsync(IEnumerable<TableReference> sources, TableReference destination, CreateCopyJobOptions options = null, CancellationToken cancellationToken = default)

Asynchronously creates a job to copy data from at least one table to another.

Parameters
NameDescription
sourcesIEnumerableTableReference

The source tables to copy. Must not be null or empty.

destinationTableReference

The destination to copy to. Must not be null.

optionsCreateCopyJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskBigQueryJob

A task representing the asynchronous operation. When complete, the result is the job created for the copy operation.

Overrides Remarks

To avoid confusion between source and destination tables, overloads are not provided that take the individual components of table references. Instead, use GetTableReference(string, string) or GetTableReference(string, string, string) to create table references.

CreateDataset(DatasetReference, Dataset, CreateDatasetOptions)

public override BigQueryDataset CreateDataset(DatasetReference datasetReference, Dataset resource = null, CreateDatasetOptions options = null)

Creates the specified dataset.

Parameters
NameDescription
datasetReferenceDatasetReference

A fully-qualified identifier for the dataset. Must not be null.

resourceDataset

The dataset resource representation to use for the creation. May be null in which case default values will be used.

optionsCreateDatasetOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryDataset

The created dataset.

Overrides Remarks

If resourceDatasetReference is specified, then it must be the same as the DatasetReference obtained from the other parameters.

CreateDatasetAsync(DatasetReference, Dataset, CreateDatasetOptions, CancellationToken)

public override Task<BigQueryDataset> CreateDatasetAsync(DatasetReference datasetReference, Dataset resource = null, CreateDatasetOptions options = null, CancellationToken cancellationToken = default)

Asynchronously creates the specified dataset.

Parameters
NameDescription
datasetReferenceDatasetReference

A fully-qualified identifier for the dataset. Must not be null.

resourceDataset

The dataset resource representation to use for the creation. May be null in which case default values will be used.

optionsCreateDatasetOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskBigQueryDataset

A task representing the asynchronous operation. When complete, the result is the created dataset.

Overrides Remarks

If resourceDatasetReference is specified, then it must be the same as the DatasetReference obtained from the other parameters.

CreateExtractJob(TableReference, IEnumerable<string>, CreateExtractJobOptions)

public override BigQueryJob CreateExtractJob(TableReference tableReference, IEnumerable<string> destinationUris, CreateExtractJobOptions options = null)

Creates a job to extract data from the specified BigQuery table to Google Cloud Storage. See the BigQuery documentation for more information on extract jobs.

Parameters
NameDescription
tableReferenceTableReference

A fully-qualified identifier for the table. Must not be null.

destinationUrisIEnumerablestring

The Google Cloud Storage URIs (possibly including a wildcard) to extract the data to. Must not be null or empty.

optionsCreateExtractJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryJob

The job created for the extract operation.

Overrides

CreateExtractJobAsync(TableReference, IEnumerable<string>, CreateExtractJobOptions, CancellationToken)

public override Task<BigQueryJob> CreateExtractJobAsync(TableReference tableReference, IEnumerable<string> destinationUris, CreateExtractJobOptions options = null, CancellationToken cancellationToken = default)

Asynchronously creates a job to extract data from the specified BigQuery table to Google Cloud Storage. See the BigQuery documentation for more information on extract jobs.

Parameters
NameDescription
tableReferenceTableReference

A fully-qualified identifier for the table. Must not be null.

destinationUrisIEnumerablestring

The Google Cloud Storage URIs (possibly including a wildcard) to extract the data to. Must not be null or empty.

optionsCreateExtractJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskBigQueryJob

A task representing the asynchronous operation. When complete, the result is the job created for the extract operation.

Overrides

CreateLoadJob(IEnumerable<string>, TableReference, TableSchema, CreateLoadJobOptions)

public override BigQueryJob CreateLoadJob(IEnumerable<string> sourceUris, TableReference destination, TableSchema schema, CreateLoadJobOptions options = null)

Creates a job to load data from at least one Google Cloud Storage file to a BigQuery table.

Parameters
NameDescription
sourceUrisIEnumerablestring

The Google Cloud Storage URIs of the files to load. Must not be null or empty.

destinationTableReference

The destination table to write data to. Must not be null.

schemaTableSchema

The schema for the table. May be null if the load operation does not require a schema, such as if the table already exists, the data is being loaded from a Google Cloud Datastore backup, or if the options are set to autodetect the schema.

optionsCreateLoadJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryJob

The job created for the load operation.

Overrides Remarks

To avoid confusion between source and destination tables, overloads are not provided that take the individual components of table references. Instead, use GetTableReference(string, string) or GetTableReference(string, string, string) to create table references.

CreateLoadJobAsync(IEnumerable<string>, TableReference, TableSchema, CreateLoadJobOptions, CancellationToken)

public override Task<BigQueryJob> CreateLoadJobAsync(IEnumerable<string> sourceUris, TableReference destination, TableSchema schema, CreateLoadJobOptions options = null, CancellationToken cancellationToken = default)

Asynchronously creates a job to load data from at least one Google Cloud Storage file to a BigQuery table.

Parameters
NameDescription
sourceUrisIEnumerablestring

The Google Cloud Storage URIs of the files to load. Must not be null or empty.

destinationTableReference

The destination table to write data to. Must not be null.

schemaTableSchema

The schema for the table. May be null if the load operation does not require a schema, such as if the table already exists, the data is being loaded from a Google Cloud Datastore backup, or if the options are set to autodetect the schema.

optionsCreateLoadJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskBigQueryJob

A task representing the asynchronous operation. When complete, the result is the job created for the load operation.

Overrides Remarks

To avoid confusion between source and destination tables, overloads are not provided that take the individual components of table references. Instead, use GetTableReference(string, string) or GetTableReference(string, string, string) to create table references.

CreateModelExtractJob(ModelReference, IEnumerable<string>, CreateModelExtractJobOptions)

public override BigQueryJob CreateModelExtractJob(ModelReference modelReference, IEnumerable<string> destinationUris, CreateModelExtractJobOptions options = null)

Creates a job to extract the specified BigQuery model to Google Cloud Storage. See the BigQuery documentation for more information on model extract jobs.

Parameters
NameDescription
modelReferenceModelReference

A fully-qualified identifier for the model. Must not be null.

destinationUrisIEnumerablestring

The Google Cloud Storage URIs (possibly including a wildcard) to extract the model to. Must not be null or empty.

optionsCreateModelExtractJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryJob

The job created for the extract operation.

Overrides

CreateModelExtractJobAsync(ModelReference, IEnumerable<string>, CreateModelExtractJobOptions, CancellationToken)

public override Task<BigQueryJob> CreateModelExtractJobAsync(ModelReference modelReference, IEnumerable<string> destinationUris, CreateModelExtractJobOptions options = null, CancellationToken cancellationToken = default)

Asynchronously creates a job to extract the specified BigQuery model to Google Cloud Storage. See the BigQuery documentation for more information on model extract jobs.

Parameters
NameDescription
modelReferenceModelReference

A fully-qualified identifier for the model. Must not be null.

destinationUrisIEnumerablestring

The Google Cloud Storage URIs (possibly including a wildcard) to extract the model to. Must not be null or empty.

optionsCreateModelExtractJobOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskBigQueryJob

A task representing the asynchronous operation. When complete, the result is the job created for the extract operation.

Overrides

CreateQueryJob(string, IEnumerable<BigQueryParameter>, QueryOptions)

public override BigQueryJob CreateQueryJob(string sql, IEnumerable<BigQueryParameter> parameters, QueryOptions options = null)

Creates a job for a SQL query.

Parameters
NameDescription
sqlstring

The SQL query. Must not be null.

parametersIEnumerableBigQueryParameter

The parameters for the query. May be null, which is equivalent to specifying an empty list of parameters. Must not contain null elements.

optionsQueryOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryJob

The query job created. Use GetQueryResults(JobReference, GetQueryResultsOptions) to retrieve the results of the query.

Overrides

CreateQueryJobAsync(string, IEnumerable<BigQueryParameter>, QueryOptions, CancellationToken)

public override Task<BigQueryJob> CreateQueryJobAsync(string sql, IEnumerable<BigQueryParameter> parameters, QueryOptions options = null, CancellationToken cancellationToken = default)

Asynchronously creates a job for a SQL query.

Parameters
NameDescription
sqlstring

The SQL query. Must not be null.

parametersIEnumerableBigQueryParameter

The parameters for the query. May be null, which is equivalent to specifying an empty list of parameters. Must not contain null elements.

optionsQueryOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskBigQueryJob

A task representing the asynchronous operation. When complete, the result is the query job created. Use GetQueryResultsAsync(JobReference, GetQueryResultsOptions, CancellationToken) to retrieve the results of the query.

Overrides

CreateRoutine(RoutineReference, Routine, CreateRoutineOptions)

public override BigQueryRoutine CreateRoutine(RoutineReference routineReference, Routine resource, CreateRoutineOptions options = null)

Creates the specified routine.

Parameters
NameDescription
routineReferenceRoutineReference

A fully-qualified identifier for the routine. Must not be null.

resourceRoutine

The routine resource representation to use for the creation. Must not be null. If this routine's RoutineReference is specified, then it must be the same as the one obtained from the other parameters, else it will be set to the one obtained from the other parameters.

optionsCreateRoutineOptions

The options for the operation. May be null, in which case defaults will be supplied.

Returns
TypeDescription
BigQueryRoutine

The newly created routine.

Overrides

CreateRoutineAsync(RoutineReference, Routine, CreateRoutineOptions, CancellationToken)

public override Task<BigQueryRoutine> CreateRoutineAsync(RoutineReference routineReference, Routine resource, CreateRoutineOptions options = null, CancellationToken cancellationToken = default)

Asynchronously creates the specified routine.

Parameters
NameDescription
routineReferenceRoutineReference

A fully-qualified identifier for the routine. Must not be null.

resourceRoutine

The routine resource representation to use for the creation. Must not be null. If this routine's RoutineReference is specified, then it must be the same as the one obtained from the other parameters, else it will be set to the one obtained from the other parameters.

optionsCreateRoutineOptions

The options for the operation. May be null, in which case defaults will be supplied.

cancellationToken