Google BigQuery v2 API - Class JobCreationOptions (3.3.0)

public abstract class JobCreationOptions

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

Base class for options for operations that create jobs.

Inheritance

object > JobCreationOptions

Namespace

GoogleGoogle.CloudGoogle.Cloud.BigQueryV2

Assembly

Google.Cloud.BigQuery.V2.dll

Properties

JobId

public string JobId { get; set; }

If specified, this ID will be used to create the job. It is an error to set both this property and JobIdPrefix.

Property Value
TypeDescription
string

JobIdPrefix

public string JobIdPrefix { get; set; }

If specified, use this prefix when generating a job ID. (Job IDs are always generated client-side by this library, to allow insertion to be retried where necessary.) It is an error to set both this property and JobId.

Property Value
TypeDescription
string

JobLocation

public string JobLocation { get; set; }

If specified, the job will be created in this location. Otherwise, it will be created in the client's default location.

Property Value
TypeDescription
string
See Also

Labels

public IDictionary<string, string> Labels { get; set; }

The labels associated with the job to be created. Labels are key-value pairs. You can use these to organize and group your jobs. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. If a label value is

null
, it won't be added to the job's labels. A label value can be Empty. Label keys must start with a letter.

Property Value
TypeDescription
IDictionarystringstring
Example
IDictionary<string, string> labels = new Dictionary<string, string>()
{
    {"label-key", "label-value" }
};

BigQueryClient client = BigQueryClient.Create(projectId);
BigQueryTable table = client.GetTable(projectId, datasetId, tableId);
string destinationUri = $"gs://{bucketName}/{objectName}";

// Just a couple examples of jobs marked with labels:
// (These jobs will most certainly be created somewhere else.)
// Running a query on a given table.
BigQueryJob oneLabeledJob = client.CreateQueryJob(
    $"SELECT * FROM {table}", null,
    new QueryOptions { Labels = labels });
// Extracting data from a table to GCS.
BigQueryJob anotherLabeledJob = client.CreateExtractJob(
    projectId, datasetId, tableId, destinationUri,
    new CreateExtractJobOptions { Labels = labels });

// Find jobs marked with a certain label.
KeyValuePair<string, string> labelToBeFound = labels.First();
        // Specify full projection to make sure that
        // label information, if it exists, is returned for listed jobs.
ListJobsOptions options = new ListJobsOptions { Projection = ProjectionEnum.Full };
List <BigQueryJob> jobs = client
    .ListJobs(options)
    .Where(job => job.Resource.Configuration.Labels?.Contains(labelToBeFound) ?? false)
    .Take(2)
    .ToList();
foreach (BigQueryJob job in jobs)
{
    Console.WriteLine(job.Reference.JobId);
}

ProjectId

public string ProjectId { get; set; }

The ID of the project in which to create the job. If this is not set, it defaults to the project ID of the client.

Property Value
TypeDescription
string