As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

google.cloud.bigquery.job.QueryJobConfig

class google.cloud.bigquery.job.QueryJobConfig(**kwargs)[source]

Configuration options for query jobs.

All properties in this class are optional. Values which are None -> server defaults. Set properties on the constructed configuration by using the property name as the name of a keyword argument.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(**kwargs)

Initialize self.

from_api_repr(resource)

Factory: construct a job configuration given its API representation

to_api_repr()

Build an API representation of the query job config.

Attributes

allow_large_results

Allow large query results tables (legacy SQL, only)

clustering_fields

Fields defining clustering for the table

create_disposition

Specifies behavior for creating tables.

default_dataset

the default dataset to use for unqualified table names in the query or None if not set.

destination

table where results are written or None if not set.

destination_encryption_configuration

Custom encryption configuration for the destination table.

dry_run

True if this query should be a dry run to estimate costs.

flatten_results

Flatten nested/repeated fields in results.

labels

Labels for the job.

maximum_billing_tier

Deprecated.

maximum_bytes_billed

Maximum bytes to be billed for this job or None if not set.

priority

Priority of the query.

query_parameters

list of parameters for parameterized query (empty by default)

range_partitioning

Optional[google.cloud.bigquery.table.RangePartitioning]: Configures range-based partitioning for destination table.

schema_update_options

Specifies updates to the destination table schema to allow as a side effect of the query job.

table_definitions

Dict[str, google.cloud.bigquery.external_config.ExternalConfig]: Definitions for external tables or None if not set.

time_partitioning

Specifies time-based partitioning for the destination table.

udf_resources

user defined function resources (empty by default)

use_legacy_sql

Use legacy SQL syntax.

use_query_cache

Look for the query result in the cache.

write_disposition

Action that occurs if the destination table already exists.

property allow_large_results

Allow large query results tables (legacy SQL, only)

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.allow_large_results

Type

bool

property clustering_fields

Fields defining clustering for the table

(Defaults to None).

Clustering fields are immutable after table creation.

Note

As of 2018-06-29, clustering fields cannot be set on a table which does not also have time partioning defined.

Type

Optional[List[str]]

property create_disposition

Specifies behavior for creating tables.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.create_disposition

Type

google.cloud.bigquery.job.CreateDisposition

property default_dataset

the default dataset to use for unqualified table names in the query or None if not set.

The default_dataset setter accepts:

  • a Dataset, or

  • a DatasetReference, or

  • a str of the fully-qualified dataset ID in standard SQL format. The value must included a project ID and dataset ID separated by .. For example: your-project.your_dataset.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.default_dataset

Type

google.cloud.bigquery.dataset.DatasetReference

property destination

table where results are written or None if not set.

The destination setter accepts:

  • a Table, or

  • a TableReference, or

  • a str of the fully-qualified table ID in standard SQL format. The value must included a project ID, dataset ID, and table ID, each separated by .. For example: your-project.your_dataset.your_table.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.destination_table

Type

google.cloud.bigquery.table.TableReference

property destination_encryption_configuration

Custom encryption configuration for the destination table.

Custom encryption configuration (e.g., Cloud KMS keys) or None if using default encryption.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.destination_encryption_configuration

Type

google.cloud.bigquery.encryption_configuration.EncryptionConfiguration

property dry_run

True if this query should be a dry run to estimate costs.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfiguration.FIELDS.dry_run

Type

bool

property flatten_results

Flatten nested/repeated fields in results. (Legacy SQL only)

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.flatten_results

Type

bool

classmethod from_api_repr(resource)

Factory: construct a job configuration given its API representation

Parameters

resource (Dict) – An extract job configuration in the same representation as is returned from the API.

Returns

Configuration parsed from resource.

Return type

google.cloud.bigquery.job._JobConfig

property labels

Labels for the job.

This method always returns a dict. To change a job’s labels, modify the dict, then call Client.update_job. To delete a label, set its value to None before updating.

Raises

ValueError – If value type is invalid.

Type

Dict[str, str]

property maximum_billing_tier

Deprecated. Changes the billing tier to allow high-compute queries.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.maximum_billing_tier

Type

int

property maximum_bytes_billed

Maximum bytes to be billed for this job or None if not set.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.maximum_bytes_billed

Type

int

property priority

Priority of the query.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.priority

Type

google.cloud.bigquery.job.QueryPriority

property query_parameters

list of parameters for parameterized query (empty by default)

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.query_parameters

Type

List[Union[google.cloud.bigquery.query.ArrayQueryParameter, google.cloud.bigquery.query.ScalarQueryParameter, google.cloud.bigquery.query.StructQueryParameter]]

property range_partitioning

Optional[google.cloud.bigquery.table.RangePartitioning]: Configures range-based partitioning for destination table.

Note

Beta. The integer range partitioning feature is in a pre-release state and might change or have limited support.

Only specify at most one of time_partitioning or range_partitioning.

Raises

ValueError – If the value is not RangePartitioning or None.

property schema_update_options

Specifies updates to the destination table schema to allow as a side effect of the query job.

Type

List[google.cloud.bigquery.job.SchemaUpdateOption]

property table_definitions

Dict[str, google.cloud.bigquery.external_config.ExternalConfig]: Definitions for external tables or None if not set.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.external_table_definitions

property time_partitioning

Specifies time-based partitioning for the destination table.

Only specify at most one of time_partitioning or range_partitioning.

Raises

ValueError – If the value is not TimePartitioning or None.

Type

Optional[google.cloud.bigquery.table.TimePartitioning]

to_api_repr()[source]

Build an API representation of the query job config.

Returns

A dictionary in the format used by the BigQuery API.

Return type

Dict

property udf_resources

user defined function resources (empty by default)

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.user_defined_function_resources

Type

List[google.cloud.bigquery.query.UDFResource]

property use_legacy_sql

Use legacy SQL syntax.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.use_legacy_sql

Type

bool

property use_query_cache

Look for the query result in the cache.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.use_query_cache

Type

bool

property write_disposition

Action that occurs if the destination table already exists.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.write_disposition

Type

google.cloud.bigquery.job.WriteDisposition