airflow.providers.google.cloud.operators.spanner

This module contains Google Spanner operators.

Module Contents

class airflow.providers.google.cloud.operators.spanner.SpannerDeployInstanceOperator(*, instance_id: str, configuration_name: str, node_count: int, display_name: str, project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Creates a new Cloud Spanner instance, or if an instance with the same instance_id exists in the specified project, updates the Cloud Spanner instance.

See also

For more information on how to use this operator, take a look at the guide: SpannerDeployInstanceOperator

Parameters
  • instance_id (str) – Cloud Spanner instance ID.

  • configuration_name (str) – The name of the Cloud Spanner instance configuration defining how the instance will be created. Required for instances that do not yet exist.

  • node_count (int) – (Optional) The number of nodes allocated to the Cloud Spanner instance.

  • display_name (str) – (Optional) The display name for the Cloud Spanner instance in the Google Cloud Console. (Must be between 4 and 30 characters.) If this value is not set in the constructor, the name is the same as the instance ID.

  • project_id (str) – Optional, the ID of the project which owns the Cloud Spanner Database. If set to None or missing, the default project_id from the Google Cloud connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud.

  • impersonation_chain (Union[str, Sequence[str]]) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'instance_id', 'configuration_name', 'display_name', 'gcp_conn_id', 'impersonation_chain'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.providers.google.cloud.operators.spanner.SpannerDeleteInstanceOperator(*, instance_id: str, project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Deletes a Cloud Spanner instance. If an instance does not exist, no action is taken and the operator succeeds.

See also

For more information on how to use this operator, take a look at the guide: SpannerDeleteInstanceOperator

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the Google Cloud connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud.

  • impersonation_chain (Union[str, Sequence[str]]) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'instance_id', 'gcp_conn_id', 'impersonation_chain'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.providers.google.cloud.operators.spanner.SpannerQueryDatabaseInstanceOperator(*, instance_id: str, database_id: str, query: Union[str, List[str]], project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Executes an arbitrary DML query (INSERT, UPDATE, DELETE).

See also

For more information on how to use this operator, take a look at the guide: SpannerQueryDatabaseInstanceOperator

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • database_id (str) – The Cloud Spanner database ID.

  • query (str or list) – The query or list of queries to be executed. Can be a path to a SQL file.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the Google Cloud connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud.

  • impersonation_chain (Union[str, Sequence[str]]) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'instance_id', 'database_id', 'query', 'gcp_conn_id', 'impersonation_chain'][source]
template_ext = ['.sql'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
static sanitize_queries(queries: List[str])[source]

Drops empty query in queries.

Parameters

queries (List[str]) – queries

Return type

None

class airflow.providers.google.cloud.operators.spanner.SpannerDeployDatabaseInstanceOperator(*, instance_id: str, database_id: str, ddl_statements: List[str], project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Creates a new Cloud Spanner database, or if database exists, the operator does nothing.

See also

For more information on how to use this operator, take a look at the guide: SpannerDeployDatabaseInstanceOperator

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • database_id (str) – The Cloud Spanner database ID.

  • ddl_statements (list[str]) – The string list containing DDL for the new database.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the Google Cloud connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud.

  • impersonation_chain (Union[str, Sequence[str]]) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id', 'impersonation_chain'][source]
template_ext = ['.sql'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.providers.google.cloud.operators.spanner.SpannerUpdateDatabaseInstanceOperator(*, instance_id: str, database_id: str, ddl_statements: List[str], project_id: Optional[str] = None, operation_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Updates a Cloud Spanner database with the specified DDL statement.

See also

For more information on how to use this operator, take a look at the guide: SpannerUpdateDatabaseInstanceOperator

Parameters
  • instance_id (str) – The Cloud Spanner instance ID.

  • database_id (str) – The Cloud Spanner database ID.

  • ddl_statements (list[str]) – The string list containing DDL to apply to the database.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the Google Cloud connection is used.

  • operation_id (str) – (Optional) Unique per database operation id that can be specified to implement idempotency check.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud.

  • impersonation_chain (Union[str, Sequence[str]]) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id', 'impersonation_chain'][source]
template_ext = ['.sql'][source]
_validate_inputs(self)[source]
execute(self, context)[source]
class airflow.providers.google.cloud.operators.spanner.SpannerDeleteDatabaseInstanceOperator(*, instance_id: str, database_id: str, project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Deletes a Cloud Spanner database.

See also

For more information on how to use this operator, take a look at the guide: SpannerDeleteDatabaseInstanceOperator

Parameters
  • instance_id (str) – Cloud Spanner instance ID.

  • database_id (str) – Cloud Spanner database ID.

  • project_id (str) – Optional, the ID of the project that owns the Cloud Spanner Database. If set to None or missing, the default project_id from the Google Cloud connection is used.

  • gcp_conn_id (str) – The connection ID used to connect to Google Cloud.

  • impersonation_chain (Union[str, Sequence[str]]) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'instance_id', 'database_id', 'gcp_conn_id', 'impersonation_chain'][source]
_validate_inputs(self)[source]
execute(self, context)[source]

Was this entry helpful?