Skip to content

Fix/get_check_result output definition to json, clarify check_definition and contract_definition #26

Merged
Jamestth merged 3 commits intomainfrom
fix/get-check-result-flatten-to-json
Apr 28, 2026
Merged

Fix/get_check_result output definition to json, clarify check_definition and contract_definition #26
Jamestth merged 3 commits intomainfrom
fix/get-check-result-flatten-to-json

Conversation

@Jamestth
Copy link
Copy Markdown
Contributor

@Jamestth Jamestth commented Apr 28, 2026

Problem

get_check_results_df() had two issues with how it handled contract_definition:

  1. Flattened into top-level columns — contract definition fields were spread as individual columns in the check results CSV. Since these fields vary based on how the contract is defined, the column set was not stable across different contracts.

  2. Contained the generated check definition, not the raw contract content — for user-authored SQL checks this was invisible (both are the same dict), but for auto-generated checks (e.g. logicalType, logicalTypeOptions) the contract_definition showed a fully synthesised SQL check object instead of the raw contract value at the JSONPath. For example, a logicalTypeOptions.minLength check at path $.schema[0].properties[1].logicalTypeOptions.minLength would show:

    {
      "name": "payroll_id_logical_type_options_minLength_check",
      "type": "sql",
      "query": "SELECT COUNT(*) ...",
      "mustBe": 0
    }

    instead of the actual contract content: {"value": 36}.

Changes

New check_definition field

Contains the resolved/generated check dict (what was previously called contract_definition). For generated checks, a "vowl_generated_check" tag is appended to tags so consumers can distinguish generated checks programmatically.

contract_definition now contains raw contract content

Resolved directly from the contract YAML via the check's JSONPath. For user-authored quality checks, this is the original ODCS quality entry. For generated checks, it's the raw value at the path (e.g. {"value": 36} for a scalar like minLength).

Separate opt-in flags on get_check_results_df() and save()

  • include_check_definition — appends the check_definition JSON column
  • include_contract_definition — appends the contract_definition JSON column
  • Both default to False (previously contract_definition was flattened into top-level columns by default)

Files changed

File Change
src/vowl/contracts/check_reference_base.py Added check_definition to CheckResultMetadata, new get_raw_contract_definition() method, vowl_generated_check tag for generated checks
src/vowl/contracts/check_reference_library_metrics.py Auto-description enrichment targets check_definition instead of contract_definition
src/vowl/validation/result.py Separate include_check_definition / include_contract_definition flags, no longer flattens contract fields into top-level columns
tests/conftest.py _is_expected_error reads from check_definition
Test files Updated stubs and assertions to use check_definition
Golden CSVs Regenerated (contract fields no longer flattened as top-level columns)

Breaking changes

  • The check results DataFrame no longer flattens contract_definition fields (like query, mustBe, tags) into top-level columns. These are now only available as JSON inside the check_definition / contract_definition columns when opted in.
  • Code that reads metadata["contract_definition"] to access the resolved check dict should now use metadata["check_definition"].

Jamestth and others added 2 commits April 28, 2026 15:01
…ning

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@Jamestth Jamestth requested a review from a team April 28, 2026 07:22
@Jamestth Jamestth changed the title Fix/get check result flatten to json Fix/get_check_result output definition to json, clarify check_definition and contract_definition Apr 28, 2026
@Jamestth Jamestth merged commit df7e4bb into main Apr 28, 2026
7 checks passed
@Jamestth Jamestth deleted the fix/get-check-result-flatten-to-json branch April 28, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants