Add --metadata-only to datacontract test and ci - #1470
Conversation
764d475 to
ca03147
Compare
|
Wouldn't it rather be |
Wow thanks for the quick feedback! 😮 I thought it seemed like the --checks was to handle the various ODCS sections and having a flag for --metadata-only then could let people toggle something that is outside of those ODCS sections and does something slightly different. And could help be a bit of a blanket safety net for testing where the user might want to say 'don't spend money in this job' but still see what the job would be doing if they just let it run. Also partly because Jakob agreed to this on Slack 😄 But I can also see how it could be part of just checks if we're happy to break that convention and if we don't care about having a 'only run cheap tests' toggle option that highlights it. Happy to update if needs be, but I thought it's also nice to see that it's skipping certain checks in the reporting now with this. Would you prefer it to be --checks metadata and just omit the non-matching checks? |
With the flag, only checks that read the schema run (field presence and types); checks that read row values (required, unique, range, pattern, enum, row count, service levels, custom SQL) show as skipped. This lets CI check the schema without paying for warehouse row scans. JSON file and API record validation still run as before. Also accept the ODCS terms properties and slaProperties in --checks, keeping schema and servicelevel as legacy names, and note in the docs that schema checks can read data.
ca03147 to
eb51cf2
Compare
As discussed with @jschoedl on Slack: add
--metadata-only, align--checksnaming with the ODCS terms, and document that schema checks can read data.Problem
datacontract test --checks schemaruns every check derived from the contract'sproperties. Some checks read only the schema, while others read row values.Row-value checks can scan large warehouse tables and add cost. There was no way to check field presence and types without also running checks such as
required,unique, ranges, patterns, row counts, service levels, and custom SQL.The command also used
schemaandservicelevelas category names instead of the ODCS termspropertiesandslaProperties.Solution
Add
--metadata-onlytodatacontract testanddatacontract ci.With the flag:
skipped.<skipped>test cases.The flag treats field presence and type metrics as schema reads. It treats all other metrics as row reads, so new metrics are skipped by default.
--checksnow accepts the ODCS termspropertiesandslaProperties.schemaandservicelevelremain as legacy aliases. Category and dimension names now match without regard to case.Behaviour worth reviewing
--metadata-onlyapplies after--checks,--dimension,--quality-id, and--tag, so these options combine.unknown. As before,testexits with code 1 for an unknown run, whilecifollows--fail-onand exits with code 0 by default.Notes
_set_resultrenamed to publicset_result(with->Noneand a docstring) because the metadata-only partition indata_contract_test.pycalls it from another module.Tests
Added tests for:
testandcioptions.Also checked the CLI with CSV and Parquet data, including text, JSON, JUnit, help output, aliases, and exit codes.
Full test suite:
Docs
Updated the testing guide to explain:
propertiesis not metadata-only.--metadata-onlyskips.Regenerated the
testandcicommand pages from CLI help, and added the entries to the release notes page.uv run pytest)uv run ruff check --fix && uv run ruff format)