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)None[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

connection_properties

Connection properties.

create_disposition

Specifies behavior for creating tables.

create_session

[Preview] If True, creates a new session, where session_info will contain a random server generated session id.

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.

job_timeout_ms

Optional parameter.

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.

script_options

Options controlling the execution of scripts.

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.

__setattr__(name, value)

Override to be able to raise error if an unknown property is being set

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

BigQuery supports clustering for both partitioned and non-partitioned tables.

Type

Optional[List[str]]

property connection_properties: List[google.cloud.bigquery.query.ConnectionProperty]

Connection properties.

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

New in version 2.29.0.

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 create_session: Optional[bool]

[Preview] If True, creates a new session, where session_info will contain a random server generated session id.

If False, runs query with an existing session_id passed in connection_properties, otherwise runs query in non-session mode.

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

New in version 2.29.0.

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: dict)google.cloud.bigquery.job.base._JobConfig

Factory: construct a job configuration given its API representation

Parameters

resource (Dict) – A 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 job_timeout_ms

Optional parameter. Job timeout in milliseconds. If this time limit is exceeded, BigQuery might attempt to stop the job. https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfiguration.FIELDS.job_timeout_ms e.g.

job_config = bigquery.QueryJobConfig( job_timeout_ms = 5000 ) or job_config.job_timeout_ms = 5000

Raises

ValueError – If value type is invalid.

property labels

Labels for the job.

This method always returns a dict. Once a job has been created on the server, its labels cannot be modified anymore.

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 script_options: google.cloud.bigquery.job.query.ScriptOptions

Options controlling the execution of scripts.

https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#scriptoptions

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()dict[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