Skip to main content
Version: 1.15.1

ValidationDefinition

Signature

class great_expectations.ValidationDefinition(
*,
name: str,
data: great_expectations.core.batch_definition.BatchDefinition,
suite: great_expectations.core.expectation_suite.ExpectationSuite,
id: Optional[str] = None
)

Responsible for running a suite against data and returning a validation result.

Parameters

NameDescription

name

The name of the validation.

data

A batch definition to validate.

suite

A grouping of expectations to validate against the data.

id

A unique identifier for the validation; added when persisted with a store.

Properties

NameDescriptionReference

asset

The parent Data Asset of the Batch Definition.

DataAsset

batch_definition

The Batch Definition to validate.

BatchDefinition

Methods

get_unexpected_rows

Signature

get_unexpected_rows(
expectation: Expectation,
batch_parameters: Optional[BatchParameters] = None,
expectation_parameters: Optional[SuiteParameterDict] = None
)list[dict]

Fetch all failing rows for an UnexpectedRowsExpectation without the 200-row limit.

Parameters

NameDescription

expectation

The UnexpectedRowsExpectation to fetch rows for. Only UnexpectedRowsExpectation is currently supported; other types raise ValueError.

batch_parameters

Optional batch parameters for selecting the correct batch. Pass result.batch_parameters when using partitioned data.

expectation_parameters

Optional suite parameter values for resolving parameterized queries (the $PARAMETER syntax). Only needed if the expectation uses a suite parameter reference for unexpected_rows_query.

Returns

TypeDescription

list[dict]

A list of dicts, one per failing row.

Raises

TypeDescription

ValueError

If the expectation is not an UnexpectedRowsExpectation, if unexpected_rows_query is a suite parameter reference but no expectation_parameters are provided, or if the suite parameter does not resolve to a string.

TypeError

If unexpected_rows_query is neither a string nor a supported suite parameter reference.

RuntimeError

If the underlying metric computation fails.

SuiteParameterError

If a referenced suite parameter is missing or invalid.

run

Signature

run(
*,
checkpoint_id: Optional[str] = None,
batch_parameters: Optional[BatchParameters] = None,
expectation_parameters: Optional[SuiteParameterDict] = None,
result_format: ResultFormatUnion = ResultFormat.SUMMARY,
run_id: RunIdentifier | None = None
) → ExpectationSuiteValidationResult

Runs a validation using the configured data and suite.

Parameters

NameDescription

batch_parameters

The dictionary of parameters necessary for selecting the correct batch to run the validation on. The keys are strings that are determined by the BatchDefinition used to instantiate this ValidationDefinition. For example:

  • whole table -> None
  • yearly -> year
  • monthly -> year, month
  • daily -> year, month, day

expectation_parameters

A dictionary of parameters values for any expectations using parameterized values (the $PARAMETER syntax). The keys are the parameter names and the values are the values to be used for this validation run.

result_format

A parameter controlling how much diagnostic information the result contains.

checkpoint_id

This is used by the checkpoints code when it runs a validation definition. Otherwise, it should be None.

run_id

An identifier for this run. Typically, this should be set to None and it will be generated by this call.

save

Signature

save()None

Save the current state of this ValidationDefinition.