Skip to main content

QueryExpectation

class great_expectations.expectations.expectation.QueryExpectation(configuration: Optional[great_expectations.core.expectation_configuration.ExpectationConfiguration] = None)#

Base class for QueryExpectations.

QueryExpectations facilitate the execution of SQL or Spark-SQL queries as the core logic for an Expectation.

QueryExpectations must implement a _validate(…) method containing logic for determining whether data returned by the executed query is successfully validated.

Query Expectations may optionally provide implementations of:

  1. validate_configuration, which should raise an error if the configuration will not be usable for the Expectation.

  2. Data Docs rendering methods decorated with the @renderer decorator.

QueryExpectations may optionally define a query attribute, and specify that query as a default in default_kwarg_values.

Doing so precludes the need to pass a query into the Expectation. This default will be overridden if a query is passed in.

Parameters:
  • domain_keys (tuple) – A tuple of the keys used to determine the domain of the expectation.

  • success_keys (tuple) – A tuple of the keys used to determine the success of the expectation.

  • runtime_keys (optional[tuple]) – Optional. A tuple of the keys that can be used to control output but will not affect the actual success value of the expectation (such as result_format).

  • default_kwarg_values (optional[dict]) – Optional. A dictionary that will be used to fill unspecified kwargs from the Expectation Configuration.

  • query (optional[str]) – Optional. A SQL or Spark-SQL query to be executed. If not provided, a query must be passed into the QueryExpectation.

Relevant Documentation Links
domain_type = 'table'#