Skip to content

Expectations utils

Utilities to be used by custom expectations.

validate_result(expectation, configuration, metrics, runtime_configuration, execution_engine, base_expectation)

Validates that the unexpected_index_list in the tests is corretly defined.

Additionally, it validates the expectation using the GE _validate method.

Parameters:

Name Type Description Default
expectation Expectation

Expectation to validate.

required
configuration ExpectationConfiguration

Configuration used in the test.

required
metrics dict

Test result metrics.

required
runtime_configuration Optional[dict]

Configuration used when running the expectation.

required
execution_engine Optional[ExecutionEngine]

Execution engine used in the expectation.

required
base_expectation Expectation

Base expectation to validate.

required
Source code in mkdocs/lakehouse_engine/packages/utils/expectations_utils.py
def validate_result(
    expectation: Expectation,
    configuration: ExpectationConfiguration,
    metrics: dict,
    runtime_configuration: Optional[dict],
    execution_engine: Optional[ExecutionEngine],
    base_expectation: Expectation,
) -> Any:
    """Validates that the unexpected_index_list in the tests is corretly defined.

    Additionally, it validates the expectation using the GE _validate method.

    Args:
        expectation: Expectation to validate.
        configuration: Configuration used in the test.
        metrics: Test result metrics.
        runtime_configuration: Configuration used when running the expectation.
        execution_engine: Execution engine used in the expectation.
        base_expectation: Base expectation to validate.
    """
    example_unexpected_index_list = _get_example_unexpected_index_list(
        expectation, configuration
    )

    test_unexpected_index_list = _get_test_unexpected_index_list(
        expectation.map_metric, metrics
    )
    if example_unexpected_index_list:
        if example_unexpected_index_list != test_unexpected_index_list:
            raise AssertionError(
                f"Example unexpected_index_list: {example_unexpected_index_list}\n"
                f"Test unexpected_index_list: {test_unexpected_index_list}"
            )
    return base_expectation._validate(
        expectation, configuration, metrics, runtime_configuration, execution_engine
    )