Client(
project: typing.Optional[str] = None,
credentials: typing.Optional[google.auth.credentials.Credentials] = None,
_http: typing.Optional[requests.sessions.Session] = None,
location: typing.Optional[str] = None,
default_query_job_config: typing.Optional[
google.cloud.bigquery.job.query.QueryJobConfig
] = None,
default_load_job_config: typing.Optional[
google.cloud.bigquery.job.load.LoadJobConfig
] = None,
client_info: typing.Optional[google.api_core.client_info.ClientInfo] = None,
client_options: typing.Optional[
typing.Union[
google.api_core.client_options.ClientOptions, typing.Dict[str, typing.Any]
]
] = None,
default_job_creation_mode: typing.Optional[str] = None,
)Client to bundle configuration needed for API requests.
Parameters |
|
|---|---|
| Name | Description |
project |
Optional[str]
Project ID for the project which the client acts on behalf of. Will be passed when creating a dataset / job. If not passed, falls back to the default inferred from the environment. |
credentials |
Optional[google.auth.credentials.Credentials]
The OAuth2 Credentials to use for this client. If not passed (and if no |
_http |
Optional[requests.Session]
HTTP object to make requests. Can be any object that defines |
location |
Optional[str]
Default location for jobs / datasets / tables. |
default_query_job_config |
Optional[google.cloud.bigquery.job.QueryJobConfig]
Default |
default_load_job_config |
Optional[google.cloud.bigquery.job.LoadJobConfig]
Default |
client_info |
Optional[google.api_core.client_info.ClientInfo]
The client info used to send a user-agent string along with API requests. If |
client_options |
Optional[Union[google.api_core.client_options.ClientOptions, Dict]]
Client options used to set user options on the client. API Endpoint should be set through client_options. |
default_job_creation_mode |
Optional[str]
Sets the default job creation mode used by query methods such as query_and_wait(). For lightweight queries, JOB_CREATION_OPTIONAL is generally recommended. |
Properties
default_job_creation_mode
Default job creation mode used for query execution.
default_load_job_config
Default LoadJobConfig.
Will be merged into job configs passed into the load_table_* methods.
default_query_job_config
Default QueryJobConfig or None.
Will be merged into job configs passed into the query or
query_and_wait methods.
location
Default location for jobs / datasets / tables.
Methods
cancel_job
cancel_job(
job_id: str,
project: typing.Optional[str] = None,
location: typing.Optional[str] = None,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> typing.Union[
google.cloud.bigquery.job.load.LoadJob,
google.cloud.bigquery.job.copy_.CopyJob,
google.cloud.bigquery.job.extract.ExtractJob,
google.cloud.bigquery.job.query.QueryJob,
]Attempt to cancel a job from a job ID.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel
| Parameters | |
|---|---|
| Name | Description |
job_id |
Union[ str, google.cloud.bigquery.job.LoadJob, google.cloud.bigquery.job.CopyJob, google.cloud.bigquery.job.ExtractJob, google.cloud.bigquery.job.QueryJob ]
Job identifier. |
project |
Optional[str]
ID of the project which owns the job (defaults to the client's project). |
location |
Optional[str]
Location where the job was run. Ignored if |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
Union[ google.cloud.bigquery.job.LoadJob, google.cloud.bigquery.job.CopyJob, google.cloud.bigquery.job.ExtractJob, google.cloud.bigquery.job.QueryJob, ] |
Job instance, based on the resource returned by the API. |
close
close()Close the underlying transport objects, releasing system resources.
copy_table
copy_table(
sources: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
str,
typing.Sequence[
typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
str,
]
],
],
destination: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
str,
],
job_id: typing.Optional[str] = None,
job_id_prefix: typing.Optional[str] = None,
location: typing.Optional[str] = None,
project: typing.Optional[str] = None,
job_config: typing.Optional[google.cloud.bigquery.job.copy_.CopyJobConfig] = None,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.cloud.bigquery.job.copy_.CopyJobCopy one or more tables to another table.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#jobconfigurationtablecopy
| Parameters | |
|---|---|
| Name | Description |
sources |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str, Sequence[ Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str, ] ], ]
Table or tables to be copied. |
destination |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str, ]
Table into which data is to be copied. |
job_id |
Optional[str]
The ID of the job. |
job_id_prefix |
Optional[str]
The user-provided prefix for a randomly generated job ID. This parameter will be ignored if a |
location |
Optional[str]
Location where to run the job. Must match the location of any source table as well as the destination table. |
project |
Optional[str]
Project ID of the project of where to run the job. Defaults to the client's project. |
job_config |
Optional[google.cloud.bigquery.job.CopyJobConfig]
Extra configuration options for the job. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Exceptions | |
|---|---|
| Type | Description |
TypeError |
If job_config is not an instance of CopyJobConfig class. |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.job.CopyJob |
A new copy job instance. |
create_dataset
create_dataset(
dataset: typing.Union[
str,
google.cloud.bigquery.dataset.Dataset,
google.cloud.bigquery.dataset.DatasetReference,
google.cloud.bigquery.dataset.DatasetListItem,
],
exists_ok: bool = False,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.cloud.bigquery.dataset.DatasetAPI call: create the dataset via a POST request.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/insert
Example:
from google.cloud import bigquery
client = bigquery.Client()
dataset = bigquery.Dataset('my_project.my_dataset')
dataset = client.create_dataset(dataset)
| Parameters | |
|---|---|
| Name | Description |
dataset |
Union[ google.cloud.bigquery.dataset.Dataset, google.cloud.bigquery.dataset.DatasetReference, google.cloud.bigquery.dataset.DatasetListItem, str, ]
A Dataset to create. If |
exists_ok |
Optional[bool]
Defaults to |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Exceptions | |
|---|---|
| Type | Description |
google.cloud.exceptions.Conflict |
If the dataset already exists. |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.dataset.Dataset |
A new Dataset returned from the API. |
create_job
create_job(
job_config: dict,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> typing.Union[
google.cloud.bigquery.job.load.LoadJob,
google.cloud.bigquery.job.copy_.CopyJob,
google.cloud.bigquery.job.extract.ExtractJob,
google.cloud.bigquery.job.query.QueryJob,
]Create a new job.
| Parameters | |
|---|---|
| Name | Description |
job_config |
dict
configuration job representation returned from the API. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
Union[ google.cloud.bigquery.job.LoadJob, google.cloud.bigquery.job.CopyJob, google.cloud.bigquery.job.ExtractJob, google.cloud.bigquery.job.QueryJob ] |
A new job instance. |
create_routine
create_routine(
routine: google.cloud.bigquery.routine.routine.Routine,
exists_ok: bool = False,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.cloud.bigquery.routine.routine.Routine[Beta] Create a routine via a POST request.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/routines/insert
| Parameters | |
|---|---|
| Name | Description |
routine |
google.cloud.bigquery.routine.Routine
A Routine to create. The dataset that the routine belongs to must already exist. |
exists_ok |
Optional[bool]
Defaults to |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Exceptions | |
|---|---|
| Type | Description |
google.cloud.exceptions.Conflict |
If the routine already exists. |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.routine.Routine |
A new Routine returned from the service. |
create_table
create_table(
table: typing.Union[
str,
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
],
exists_ok: bool = False,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.cloud.bigquery.table.TableAPI call: create a table via a PUT request
See https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/insert
| Parameters | |
|---|---|
| Name | Description |
table |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str, ]
A Table to create. If |
exists_ok |
Optional[bool]
Defaults to |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Exceptions | |
|---|---|
| Type | Description |
google.cloud.exceptions.Conflict |
If the table already exists. |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.table.Table |
A new Table returned from the service. |
dataset
dataset(
dataset_id: str, project: typing.Optional[str] = None
) -> google.cloud.bigquery.dataset.DatasetReferenceDeprecated: Construct a reference to a dataset.
As ofgoogle-cloud-bigquery version 1.7.0, all client methods
that take a
xref_DatasetReference or
xref_TableReference also take a
string in standard SQL format, e.g. project.dataset_id or
project.dataset_id.table_id.
| Parameters | |
|---|---|
| Name | Description |
dataset_id |
str
ID of the dataset. |
project |
Optional[str]
Project ID for the dataset (defaults to the project of the client). |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.dataset.DatasetReference |
a new DatasetReference instance. |
delete_dataset
delete_dataset(
dataset: typing.Union[
google.cloud.bigquery.dataset.Dataset,
google.cloud.bigquery.dataset.DatasetReference,
google.cloud.bigquery.dataset.DatasetListItem,
str,
],
delete_contents: bool = False,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
not_found_ok: bool = False,
) -> NoneDelete a dataset.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/delete
| Parameters | |
|---|---|
| Name | Description |
dataset |
Union[ google.cloud.bigquery.dataset.Dataset, google.cloud.bigquery.dataset.DatasetReference, google.cloud.bigquery.dataset.DatasetListItem, str, ]
A reference to the dataset to delete. If a string is passed in, this method attempts to create a dataset reference from a string using from_string. |
delete_contents |
Optional[bool]
If True, delete all the tables in the dataset. If False and the dataset contains tables, the request will fail. Default is False. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
not_found_ok |
Optional[bool]
Defaults to |
delete_job_metadata
delete_job_metadata(
job_id: typing.Union[
str,
google.cloud.bigquery.job.load.LoadJob,
google.cloud.bigquery.job.copy_.CopyJob,
google.cloud.bigquery.job.extract.ExtractJob,
google.cloud.bigquery.job.query.QueryJob,
],
project: typing.Optional[str] = None,
location: typing.Optional[str] = None,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
not_found_ok: bool = False,
)[Beta] Delete job metadata from job history.
Note: This does not stop a running job. Use xref_cancel_job instead.
| Parameters | |
|---|---|
| Name | Description |
job_id |
Union[ str, LoadJob, CopyJob, ExtractJob, QueryJob ]
Job or job identifier. |
project |
Optional[str]
ID of the project which owns the job (defaults to the client's project). |
location |
Optional[str]
Location where the job was run. Ignored if |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
not_found_ok |
Optional[bool]
Defaults to |
delete_model
delete_model(
model: typing.Union[
google.cloud.bigquery.model.Model,
google.cloud.bigquery.model.ModelReference,
str,
],
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
not_found_ok: bool = False,
) -> None[Beta] Delete a model
See https://cloud.google.com/bigquery/docs/reference/rest/v2/models/delete
| Parameters | |
|---|---|
| Name | Description |
model |
Union[ google.cloud.bigquery.model.Model, google.cloud.bigquery.model.ModelReference, str, ]
A reference to the model to delete. If a string is passed in, this method attempts to create a model reference from a string using from_string. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
not_found_ok |
Optional[bool]
Defaults to |
delete_routine
delete_routine(
routine: typing.Union[
google.cloud.bigquery.routine.routine.Routine,
google.cloud.bigquery.routine.routine.RoutineReference,
str,
],
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
not_found_ok: bool = False,
) -> None[Beta] Delete a routine.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/routines/delete
| Parameters | |
|---|---|
| Name | Description |
routine |
Union[ google.cloud.bigquery.routine.Routine, google.cloud.bigquery.routine.RoutineReference, str, ]
A reference to the routine to delete. If a string is passed in, this method attempts to create a routine reference from a string using from_string. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
not_found_ok |
Optional[bool]
Defaults to |
delete_table
delete_table(
table: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
str,
],
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
not_found_ok: bool = False,
) -> NoneDelete a table
See https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/delete
| Parameters | |
|---|---|
| Name | Description |
table |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str, ]
A reference to the table to delete. If a string is passed in, this method attempts to create a table reference from a string using from_string. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
not_found_ok |
Optional[bool]
Defaults to |
extract_table
extract_table(
source: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
google.cloud.bigquery.model.Model,
google.cloud.bigquery.model.ModelReference,
str,
],
destination_uris: typing.Union[str, typing.Sequence[str]],
job_id: typing.Optional[str] = None,
job_id_prefix: typing.Optional[str] = None,
location: typing.Optional[str] = None,
project: typing.Optional[str] = None,
job_config: typing.Optional[
google.cloud.bigquery.job.extract.ExtractJobConfig
] = None,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
source_type: str = "Table",
) -> google.cloud.bigquery.job.extract.ExtractJobStart a job to extract a table into Cloud Storage files.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#jobconfigurationextract
| Parameters | |
|---|---|
| Name | Description |
source |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, google.cloud.bigquery.model.Model, google.cloud.bigquery.model.ModelReference, src, ]
Table or Model to be extracted. |
destination_uris |
Union[str, Sequence[str]]
URIs of Cloud Storage file(s) into which table data is to be extracted; in format |
job_id |
Optional[str]
The ID of the job. |
job_id_prefix |
Optional[str]
The user-provided prefix for a randomly generated job ID. This parameter will be ignored if a |
location |
Optional[str]
Location where to run the job. Must match the location of the source table. |
project |
Optional[str]
Project ID of the project of where to run the job. Defaults to the client's project. |
job_config |
Optional[google.cloud.bigquery.job.ExtractJobConfig]
Extra configuration options for the job. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
source_type |
Optional[str]
Type of source to be extracted. |
| Exceptions | |
|---|---|
| Type | Description |
TypeError |
If job_config is not an instance of ExtractJobConfig class. |
ValueError |
If source_type is not among Table,Model. |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.job.ExtractJob |
A new extract job instance. |
get_dataset
get_dataset(
dataset_ref: typing.Union[google.cloud.bigquery.dataset.DatasetReference, str],
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
dataset_view: typing.Optional[google.cloud.bigquery.enums.DatasetView] = None,
) -> google.cloud.bigquery.dataset.DatasetFetch the dataset referenced by dataset_ref
| Parameters | |
|---|---|
| Name | Description |
dataset_ref |
Union[ google.cloud.bigquery.dataset.DatasetReference, str, ]
A reference to the dataset to fetch from the BigQuery API. If a string is passed in, this method attempts to create a dataset reference from a string using from_string. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
dataset_view |
Optional[google.cloud.bigquery.enums.DatasetView]
Specifies the view that determines which dataset information is returned. By default, dataset metadata (e.g. friendlyName, description, labels, etc) and ACL information are returned. This argument can take on the following possible enum values. * ACL: Includes dataset metadata and the ACL. * FULL: Includes all dataset metadata, including the ACL and table metadata. This view is not supported by the |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.dataset.Dataset |
A Dataset instance. |
get_iam_policy
get_iam_policy(
table: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
str,
],
requested_policy_version: int = 1,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.api_core.iam.PolicyReturn the access control policy for a table resource.
| Parameters | |
|---|---|
| Name | Description |
table |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str, ]
The table to get the access control policy for. If a string is passed in, this method attempts to create a table reference from a string using from_string. |
requested_policy_version |
int
Optional. The maximum policy version that will be used to format the policy. Only version |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
google.api_core.iam.Policy |
The access control policy. |
get_job
get_job(
job_id: typing.Union[
str,
google.cloud.bigquery.job.load.LoadJob,
google.cloud.bigquery.job.copy_.CopyJob,
google.cloud.bigquery.job.extract.ExtractJob,
google.cloud.bigquery.job.query.QueryJob,
],
project: typing.Optional[str] = None,
location: typing.Optional[str] = None,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = 128,
) -> typing.Union[
google.cloud.bigquery.job.load.LoadJob,
google.cloud.bigquery.job.copy_.CopyJob,
google.cloud.bigquery.job.extract.ExtractJob,
google.cloud.bigquery.job.query.QueryJob,
google.cloud.bigquery.job.base.UnknownJob,
]Fetch a job for the project associated with this client.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get
| Parameters | |
|---|---|
| Name | Description |
job_id |
Union[ str, job.LoadJob, job.CopyJob, job.ExtractJob, job.QueryJob ]
Job identifier. |
project |
Optional[str]
ID of the project which owns the job (defaults to the client's project). |
location |
Optional[str]
Location where the job was run. Ignored if |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
Union[job.LoadJob, job.CopyJob, job.ExtractJob, job.QueryJob, job.UnknownJob] |
Job instance, based on the resource returned by the API. |
get_model
get_model(
model_ref: typing.Union[google.cloud.bigquery.model.ModelReference, str],
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.cloud.bigquery.model.Model[Beta] Fetch the model referenced by model_ref.
| Parameters | |
|---|---|
| Name | Description |
model_ref |
Union[ google.cloud.bigquery.model.ModelReference, str, ]
A reference to the model to fetch from the BigQuery API. If a string is passed in, this method attempts to create a model reference from a string using from_string. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.model.Model |
A Model instance. |
get_routine
get_routine(
routine_ref: typing.Union[
google.cloud.bigquery.routine.routine.Routine,
google.cloud.bigquery.routine.routine.RoutineReference,
str,
],
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.cloud.bigquery.routine.routine.Routine[Beta] Get the routine referenced by routine_ref.
| Parameters | |
|---|---|
| Name | Description |
routine_ref |
Union[ google.cloud.bigquery.routine.Routine, google.cloud.bigquery.routine.RoutineReference, str, ]
A reference to the routine to fetch from the BigQuery API. If a string is passed in, this method attempts to create a reference from a string using from_string. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the API call. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.routine.Routine |
A Routine instance. |
get_service_account_email
get_service_account_email(
project: typing.Optional[str] = None,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> strGet the email address of the project's BigQuery service account
Example:
from google.cloud import bigquery
client = bigquery.Client()
client.get_service_account_email()
# returns an email similar to: my_service_account@my-project.iam.gserviceaccount.com
| Parameters | |
|---|---|
| Name | Description |
project |
Optional[str]
Project ID to use for retreiving service account email. Defaults to the client's project. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
str |
service account email address |
get_table
get_table(
table: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
str,
],
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> google.cloud.bigquery.table.TableFetch the table referenced by table.
| Parameters | |
|---|---|
| Name | Description |
table |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str, ]
A reference to the table to fetch from the BigQuery API. If a string is passed in, this method attempts to create a table reference from a string using from_string. |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Returns | |
|---|---|
| Type | Description |
google.cloud.bigquery.table.Table |
A Table instance. |
insert_rows
insert_rows(
table: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
str,
],
rows: typing.Union[
typing.Iterable[typing.Tuple], typing.Iterable[typing.Mapping[str, typing.Any]]
],
selected_fields: typing.Optional[
typing.Sequence[google.cloud.bigquery.schema.SchemaField]
] = None,
**kwargs
) -> typing.Sequence[typing.Dict[str, typing.Any]]Insert rows into a table via the streaming API.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll
BigQuery will reject insertAll payloads that exceed a defined limit (10MB). Additionally, if a payload vastly exceeds this limit, the request is rejected by the intermediate architecture, which returns a 413 (Payload Too Large) status code.
See https://cloud.google.com/bigquery/quotas#streaming_inserts
| Parameters | |
|---|---|
| Name | Description |
kwargs |
dict
Keyword arguments to insert_rows_json. |
table |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, str, ]
The destination table for the row data, or a reference to it. |
rows |
Union[Sequence[Tuple], Sequence[Dict]]
Row data to be inserted. If a list of tuples is given, each tuple should contain data for each schema field on the current table and in the same order as the schema fields. If a list of dictionaries is given, the keys must include all required fields in the schema. Keys which do not correspond to a field in the schema are ignored. |
selected_fields |
Sequence[google.cloud.bigquery.schema.SchemaField]
The fields to return. Required if |
| Exceptions | |
|---|---|
| Type | Description |
ValueError |
if table's schema is not set or rows is not a Sequence. |
| Returns | |
|---|---|
| Type | Description |
Sequence[Mappings] |
One mapping per row with insert errors: the "index" key identifies the row, and the "errors" key contains a list of the mappings describing one or more problems with the row. |
insert_rows_from_dataframe
insert_rows_from_dataframe(
table: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
str,
],
dataframe,
selected_fields: typing.Optional[
typing.Sequence[google.cloud.bigquery.schema.SchemaField]
] = None,
chunk_size: int = 500,
**kwargs: typing.Dict
) -> typing.Sequence[typing.Sequence[dict]]Insert rows into a table from a dataframe via the streaming API.
BigQuery will reject insertAll payloads that exceed a defined limit (10MB). Additionally, if a payload vastly exceeds this limit, the request is rejected by the intermediate architecture, which returns a 413 (Payload Too Large) status code.
See https://cloud.google.com/bigquery/quotas#streaming_inserts
| Parameters | |
|---|---|
| Name | Description |
kwargs |
Dict
Keyword arguments to insert_rows_json. |
table |
Union[ google.cloud.bigquery.table.Table, google.cloud.bigquery.table.TableReference, str, ]
The destination table for the row data, or a reference to it. |
dataframe |
pandas.DataFrame
A |
selected_fields |
Sequence[google.cloud.bigquery.schema.SchemaField]
The fields to return. Required if |
chunk_size |
int
The number of rows to stream in a single chunk. Must be positive. |
| Exceptions | |
|---|---|
| Type | Description |
ValueError |
if table's schema is not set |
| Returns | |
|---|---|
| Type | Description |
Sequence[Sequence[Mappings]] |
A list with insert errors for each insert chunk. Each element is a list containing one mapping per row with insert errors: the "index" key identifies the row, and the "errors" key contains a list of the mappings describing one or more problems with the row. |
insert_rows_json
insert_rows_json(
table: typing.Union[
google.cloud.bigquery.table.Table,
google.cloud.bigquery.table.TableReference,
google.cloud.bigquery.table.TableListItem,
str,
],
json_rows: typing.Sequence[typing.Mapping[str, typing.Any]],
row_ids: typing.Optional[
typing.Union[
typing.Iterable[typing.Optional[str]],
google.cloud.bigquery.enums.AutoRowIDs,
]
] = AutoRowIDs.GENERATE_UUID,
skip_invalid_rows: typing.Optional[bool] = None,
ignore_unknown_values: typing.Optional[bool] = None,
template_suffix: typing.Optional[str] = None,
retry: google.api_core.retry.retry_unary.Retry = google.api_core.retry.retry_unary.Retry,
timeout: typing.Optional[float] = None,
) -> typing.Sequence[dict]Insert rows into a table without applying local type conversions.
See https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll
BigQuery will reject insertAll payloads that exceed a defined limit (10MB). Additionally, if a payload vastly exceeds this limit, the request is rejected by the intermediate architecture, which returns a 413 (Payload Too Large) status code.
See https://cloud.google.com/bigquery/quotas#streaming_inserts
| Parameters | |
|---|---|
| Name | Description |
table |
Union[ google.cloud.bigquery.table.Table google.cloud.bigquery.table.TableReference, google.cloud.bigquery.table.TableListItem, str ]
The destination table for the row data, or a reference to it. |
json_rows |
Sequence[Dict]
Row data to be inserted. Keys must match the table schema fields and values must be JSON-compatible representations. |
row_ids |
Union[Iterable[str], AutoRowIDs, None]
Unique IDs, one per row being inserted. An ID can also be |
skip_invalid_rows |
Optional[bool]
Insert all valid rows of a request, even if invalid rows exist. The default value is |
ignore_unknown_values |
Optional[bool]
Accept rows that contain values that do not match the schema. The unknown values are ignored. Default is |
template_suffix |
Optional[str]
Treat |
retry |
Optional[google.api_core.retry.Retry]
How to retry the RPC. |
timeout |
Optional[float]
The number of seconds to wait for the underlying HTTP transport before using |
| Exceptions | |
|---|---|
| Type | Description |
TypeError |
if json_rows is not a Sequence. |
| Returns | |
|---|---|
| Type | Description |
Sequence[Mappings] |
One mapping per row with insert errors: the "index" key identifies the row, and the "errors" key contains a list of the mappings describing one or more problems with the row. |
job_from_resource
job_from_resource(
resource: dict,
) -> typing.Union[
google.cloud.bigquery.job.copy_.CopyJob,
google.cloud.bigquery.job.extract.ExtractJob,
google.cloud.bigquery.job.load.LoadJob,
google.cloud.bigquery.job.query.QueryJob,
google.cloud.bigquery.job.base.UnknownJob,
]Detect correct job type from resource and instantiate.
| Parameter | |
|---|---|
| Name | Description |
resource |
Dict
one job resource from API response |
| Returns | |
|---|---|
| Type | Description |
Union[job.CopyJob, job.ExtractJob, job.LoadJob, job.QueryJob, job.UnknownJob] |
The job instance, constructed via the resource. |
list_datasets
list_datasets(
project: typing.Optional[str] = None,
include_all: bool = False,
filter: typing.Optional[str] =