airflow.providers.neo4j.sensors.neo4j

Classes

Neo4jSensor

Executes a Cypher query in Neo4j until the returned value satisfies a condition.

Module Contents

class airflow.providers.neo4j.sensors.neo4j.Neo4jSensor(*, neo4j_conn_id='neo4j_default', cypher, parameters=None, success=None, failure=None, selector=itemgetter(0), fail_on_empty=False, **kwargs)[source]

Bases: airflow.providers.common.compat.sdk.BaseSensorOperator

Executes a Cypher query in Neo4j until the returned value satisfies a condition.

The query runs repeatedly at the defined poke interval until:
  • A callable provided in failure evaluates to True, which raises an exception.

  • A callable provided in success evaluates to True, which marks success.

  • Otherwise, the truthiness of the selected value determines success.

Example

wait_person_exists = Neo4jSensor(
    task_id="wait_person_exists",
    neo4j_conn_id="neo4j_default",
    cypher="MATCH (p:Person) RETURN count(p) > 0",
)
param neo4j_conn_id:

Connection ID to use for connecting to Neo4j.

param cypher:

Cypher statement to execute. (Templated)

param parameters:

Query parameters. (Templated)

param success:

Callable that receives the selected value and returns a boolean.

param failure:

Callable that receives the selected value; if it returns True, an error is raised.

param selector:

Function that extracts a single value from the first row of the result.

param fail_on_empty:

When True, raises if the query returns no rows.

template_fields: collections.abc.Sequence[str] = ('cypher', 'parameters')[source]
template_fields_renderers[source]
neo4j_conn_id = 'neo4j_default'[source]
cypher[source]
parameters = None[source]
success = None[source]
failure = None[source]
selector[source]
fail_on_empty = False[source]
poke(context)[source]

Override when deriving this class.

Was this entry helpful?