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_configuration Any

Expectation configuration.

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_configuration: Any,
    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_configuration: Expectation configuration.
        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_configuration.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
    )