Skip to content

Latest commit

 

History

History
291 lines (208 loc) · 9.95 KB

spanner.rst

File metadata and controls

291 lines (208 loc) · 9.95 KB

Google Cloud Spanner Operators

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

For parameter definition, take a look at :class:`~airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseDeleteOperator`.

Arguments

Some arguments in the example DAG are taken from environment variables.

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :start-after: [START howto_operator_spanner_arguments]
    :end-before: [END howto_operator_spanner_arguments]

Using the operator

You can create the operator with or without project id. If project id is missing it will be retrieved from the GCP connection used. Both variants are shown:

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :dedent: 4
    :start-after: [START howto_operator_spanner_database_delete]
    :end-before: [END howto_operator_spanner_database_delete]

Templating

.. literalinclude:: ../../../../airflow/contrib/operators/gcp_spanner_operator.py
    :language: python
    :dedent: 4
    :start-after: [START gcp_spanner_delete_template_fields]
    :end-before: [END gcp_spanner_delete_template_fields]

More information

See Google Cloud Spanner API documentation to drop an instance of a database.

Creates a new Cloud Spanner database in the specified instance, or if the desired database exists, assumes success with no changes applied to database configuration. No structure of the database is verified - it's enough if the database exists with the same name.

For parameter definition, take a look at :class:`~airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseDeployOperator`.

Arguments

Some arguments in the example DAG are taken from environment variables.

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :start-after: [START howto_operator_spanner_arguments]
    :end-before: [END howto_operator_spanner_arguments]

Using the operator

You can create the operator with or without project id. If project id is missing it will be retrieved from the GCP connection used. Both variants are shown:

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :dedent: 4
    :start-after: [START howto_operator_spanner_database_deploy]
    :end-before: [END howto_operator_spanner_database_deploy]

Templating

.. literalinclude:: ../../../../airflow/contrib/operators/gcp_spanner_operator.py
    :language: python
    :dedent: 4
    :start-after: [START gcp_spanner_database_deploy_template_fields]
    :end-before: [END gcp_spanner_database_deploy_template_fields]

More information

See Google Cloud Spanner API documentation to create a new database.

Runs a DDL query in a Cloud Spanner database and allows you to modify the structure of an existing database.

You can optionally specify an operation_id parameter which simplifies determining whether the statements were executed in case the update_database call is replayed (idempotency check). The operation_id should be unique within the database, and must be a valid identifier: [a-z][a-z0-9_]*. More information can be found in the documentation of updateDdl API

For parameter definition take a look at :class:`~airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseUpdateOperator`.

Arguments

Some arguments in the example DAG are taken from environment variables.

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :start-after: [START howto_operator_spanner_arguments]
    :end-before: [END howto_operator_spanner_arguments]

Using the operator

You can create the operator with or without project id. If project id is missing it will be retrieved from the GCP connection used. Both variants are shown:

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :dedent: 4
    :start-after: [START howto_operator_spanner_database_update]
    :end-before: [END howto_operator_spanner_database_update]

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :dedent: 4
    :start-after: [START howto_operator_spanner_database_update_idempotent]
    :end-before: [END howto_operator_spanner_database_update_idempotent]

Templating

.. literalinclude:: ../../../../airflow/contrib/operators/gcp_spanner_operator.py
    :language: python
    :dedent: 4
    :start-after: [START gcp_spanner_database_update_template_fields]
    :end-before: [END gcp_spanner_database_update_template_fields]

More information

See Google Cloud Spanner API documentation for database update_ddl.

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

For parameter definition take a look at :class:`~airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDatabaseQueryOperator`.

Arguments

Some arguments in the example DAG are taken from environment variables.

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :start-after: [START howto_operator_spanner_arguments]
    :end-before: [END howto_operator_spanner_arguments]

Using the operator

You can create the operator with or without project id. If project id is missing it will be retrieved from the GCP connection used. Both variants are shown:

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :dedent: 4
    :start-after: [START howto_operator_spanner_query]
    :end-before: [END howto_operator_spanner_query]

Templating

.. literalinclude:: ../../../../airflow/contrib/operators/gcp_spanner_operator.py
    :language: python
    :dedent: 4
    :start-after: [START gcp_spanner_query_template_fields]
    :end-before: [END gcp_spanner_query_template_fields]

More information

See Google Cloud Spanner API documentation for more information about DML syntax.

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

For parameter definition take a look at :class:`~airflow.contrib.operators.gcp_spanner_operator.CloudSpannerInstanceDeleteOperator`.

Arguments

Some arguments in the example DAG are taken from environment variables:

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :start-after: [START howto_operator_spanner_arguments]
    :end-before: [END howto_operator_spanner_arguments]

Using the operator

You can create the operator with or without project id. If project id is missing it will be retrieved from the GCP connection used. Both variants are shown:

.. exampleinclude:: ../../../../airflow/contrib/example_dags/example_gcp_spanner.py
    :language: python
    :dedent: 4
    :start-after: [START howto_operator_spanner_delete]
    :end-before: [END howto_operator_spanner_delete]

Templating

.. literalinclude:: ../../../../airflow/contrib/operators/gcp_spanner_operator.py
    :language: python
    :dedent: 4
    :start-after: [START gcp_spanner_delete_template_fields]
    :end-before: [END gcp_spanner_delete_template_fields]

More information

See Google Cloud Spanner API documentation to delete an instance.

For further information, look at: