airflow.providers.google.cloud.operators.spanner

This module contains Google Spanner operators.

Module Contents

Classes

SpannerDeployInstanceOperator

Creates a new Cloud Spanner instance, or if an instance with the same instance_id

SpannerDeleteInstanceOperator

Deletes a Cloud Spanner instance. If an instance does not exist,

SpannerQueryDatabaseInstanceOperator

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

SpannerDeployDatabaseInstanceOperator

Creates a new Cloud Spanner database, or if database exists,

SpannerUpdateDatabaseInstanceOperator

Updates a Cloud Spanner database with the specified DDL statement.

SpannerDeleteDatabaseInstanceOperator

Deletes a Cloud Spanner database.

class airflow.providers.google.cloud.operators.spanner.SpannerDeployInstanceOperator(*, instance_id, configuration_name, node_count, display_name, project_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=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 | None) – 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 (str | Sequence[str] | None) – 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 :Sequence[str] = ['project_id', 'instance_id', 'configuration_name', 'display_name', 'gcp_conn_id', 'impersonation_chain'][source]
execute(context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.spanner.SpannerDeleteInstanceOperator(*, instance_id, project_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=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 | None) – 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 (str | Sequence[str] | None) – 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 :Sequence[str] = ['project_id', 'instance_id', 'gcp_conn_id', 'impersonation_chain'][source]
execute(context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.spanner.SpannerQueryDatabaseInstanceOperator(*, instance_id, database_id, query, project_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=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 | list[str]) – The query or list of queries to be executed. Can be a path to a SQL file.

  • project_id (str | None) – 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 (str | Sequence[str] | None) – 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 :Sequence[str] = ['project_id', 'instance_id', 'database_id', 'query', 'gcp_conn_id', 'impersonation_chain'][source]
template_ext :Sequence[str] = ['.sql'][source]
template_fields_renderers[source]
execute(context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

static sanitize_queries(queries)[source]

Drops empty query in queries.

Parameters

queries (list[str]) – queries

Return type

None

class airflow.providers.google.cloud.operators.spanner.SpannerDeployDatabaseInstanceOperator(*, instance_id, database_id, ddl_statements, project_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=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 | None) – 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 (str | Sequence[str] | None) – 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 :Sequence[str] = ['project_id', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id', 'impersonation_chain'][source]
template_ext :Sequence[str] = ['.sql'][source]
template_fields_renderers[source]
execute(context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.spanner.SpannerUpdateDatabaseInstanceOperator(*, instance_id, database_id, ddl_statements, project_id=None, operation_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=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 | None) – 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 | None) – (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 (str | Sequence[str] | None) – 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 :Sequence[str] = ['project_id', 'instance_id', 'database_id', 'ddl_statements', 'gcp_conn_id', 'impersonation_chain'][source]
template_ext :Sequence[str] = ['.sql'][source]
template_fields_renderers[source]
execute(context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.spanner.SpannerDeleteDatabaseInstanceOperator(*, instance_id, database_id, project_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=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 | None) – 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 (str | Sequence[str] | None) – 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 :Sequence[str] = ['project_id', 'instance_id', 'database_id', 'gcp_conn_id', 'impersonation_chain'][source]
execute(context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?