Resolve ${VAR} references in contracts, port as string - #1568
Merged
Conversation
ODCS v3.2.0 allows ${VAR} and ${VAR:-default} in any string value.
datacontract test resolves them from the environment when it opens the
connection and when it prepares a SQL quality query, after the CLI's own
${model}-style placeholders. The loaded contract is never mutated, so
lint accepts unresolved references and export writes them back verbatim.
An unset variable without a default fails the run, or the single check,
with the variable's name. Configuration overrides such as
DATACONTRACT_POSTGRES_HOST still win over the contract. The config file
loader shares the resolver and gains the default form. Excel import keeps
a port cell that holds a reference instead of dropping it.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1559 (#1557). Targets the
odcs-3.2.0branch.ODCS v3.2.0 (RFC 0050) allows
${VAR_NAME}and${VAR_NAME:-default}in any string value. Tools must resolve them before use, should error on unresolvable ones, and must preserve them when serializing.Design
datacontract testresolves the server's fields right after the configuration overrides are applied, and each SQL quality query when the check is prepared. The loaded contract keeps the references, solintaccepts them andexport/publishwrite them back verbatim (covered by a test).datacontract/config/variables.py. The config file loader now uses it too and gains the${VAR:-default}form.DATACONTRACT_<SERVER>_<FIELD>overrides still win over the contract. In queries the CLI's own${model},${schema}, ... placeholders are substituted first, so they are not mistaken for variables.server 'prod' host), or fails just that quality check when it is in a query. Never an empty-string substitution.portholding a reference resolves to an int again; Excel import keeps a${DB_PORT}cell as a string instead of dropping it.Tests
Unit tests for the resolver and server resolution, end-to-end DuckDB tests (resolved server and queries, unset server variable, unset query variable, override wins, export keeps references), config file default form, Excel port parsing. Full suite: 2314 passed.
Docs
New "Variables in the data contract" section on the configuration page, a note on the SQL quality rules page (placeholders first, then variables), and a pointer on the testing index.
🤖 Generated with Claude Code
https://claude.ai/code/session_01C1xhK6DjRLWND1ntBcS8fG