airflow.providers.qubole.operators.qubole_check

Module Contents

Classes

QuboleCheckOperator

Performs checks against Qubole Commands.

QuboleValueCheckOperator

Performs a simple value check using Qubole command.

Functions

get_sql_from_qbol_cmd(params)

Get Qubole sql from Qubole command.

handle_airflow_exception(airflow_exception, hook)

Qubole check handle Airflow exception.

class airflow.providers.qubole.operators.qubole_check.QuboleCheckOperator(*, qubole_conn_id='qubole_default', results_parser_callable=None, **kwargs)[source]

Bases: _QuboleCheckOperatorMixin, airflow.providers.common.sql.operators.sql.SQLCheckOperator, airflow.providers.qubole.operators.qubole.QuboleOperator

Performs checks against Qubole Commands.

QuboleCheckOperator expects a command that will be executed on QDS. By default, each value on first row of the result of this Qubole Command is evaluated using python bool casting. If any of the values return False, the check is failed and errors out.

Note that Python bool casting evals the following as False:

  • False

  • 0

  • Empty string ("")

  • Empty list ([])

  • Empty dictionary or set ({})

Given a query like SELECT COUNT(*) FROM foo, it will fail only if the count == 0. You can craft much more complex query that could, for instance, check that the table has the same number of rows as the source table upstream, or that the count of today’s partition is greater than yesterday’s partition, or that a set of metrics are less than 3 standard deviation for the 7 day average.

This operator can be used as a data quality check in your pipeline, and depending on where you put it in your DAG, you have the choice to stop the critical path, preventing from publishing dubious data, or on the side and receive email alerts without stopping the progress of the DAG.

See also

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

Parameters
  • qubole_conn_id (str) – Connection id which consists of qds auth_token

  • results_parser_callable (Callable | None) – This is an optional parameter to extend the flexibility of parsing the results of Qubole command to the users. This is a Python callable which can hold the logic to parse list of rows returned by Qubole command. By default, only the values on first row are used for performing checks. This callable should return a list of records on which the checks have to be performed.

kwargs:

Arguments specific to Qubole command can be referred from QuboleOperator docs.

Note

All fields in common with template fields of QuboleOperator and SQLCheckOperator are template-supported.

conn_id_field = 'qubole_conn_id'[source]
template_fields: Sequence[str][source]
template_ext[source]
ui_fgcolor = '#000'[source]
class airflow.providers.qubole.operators.qubole_check.QuboleValueCheckOperator(*, pass_value, tolerance=None, results_parser_callable=None, qubole_conn_id='qubole_default', **kwargs)[source]

Bases: _QuboleCheckOperatorMixin, airflow.providers.common.sql.operators.sql.SQLValueCheckOperator, airflow.providers.qubole.operators.qubole.QuboleOperator

Performs a simple value check using Qubole command.

By default, each value on the first row of this Qubole command is compared with a pre-defined value. The check fails and errors out if the output of the command is not within the permissible limit of expected value.

Parameters
  • qubole_conn_id (str) – Connection id which consists of qds auth_token

  • pass_value (str | int | float) – Expected value of the query results.

  • tolerance (int | float | None) – Defines the permissible pass_value range, for example if tolerance is 2, the Qubole command output can be anything between -2*pass_value and 2*pass_value, without the operator erring out.

  • results_parser_callable (Callable | None) – This is an optional parameter to extend the flexibility of parsing the results of Qubole command to the users. This is a Python callable which can hold the logic to parse list of rows returned by Qubole command. By default, only the values on first row are used for performing checks. This callable should return a list of records on which the checks have to be performed.

kwargs:

Arguments specific to Qubole command can be referred from QuboleOperator docs.

Note

All fields in common with template fields of QuboleOperator and SQLValueCheckOperator are template-supported.

template_fields[source]
template_ext[source]
ui_fgcolor = '#000'[source]
conn_id_field = 'qubole_conn_id'[source]
airflow.providers.qubole.operators.qubole_check.get_sql_from_qbol_cmd(params)[source]

Get Qubole sql from Qubole command.

airflow.providers.qubole.operators.qubole_check.handle_airflow_exception(airflow_exception, hook)[source]

Qubole check handle Airflow exception.

Was this entry helpful?