Skip to content

fix(contracts): export all ODCS v3.1.0 fields from _build_contract_api_model#296

Closed
ashmeet-kandhari wants to merge 1 commit into
databrickslabs:mainfrom
ashmeet-kandhari:fix/odcs-v310-export-gaps
Closed

fix(contracts): export all ODCS v3.1.0 fields from _build_contract_api_model#296
ashmeet-kandhari wants to merge 1 commit into
databrickslabs:mainfrom
ashmeet-kandhari:fix/odcs-v310-export-gaps

Conversation

@ashmeet-kandhari
Copy link
Copy Markdown

Fixes #295

Problem

The d1_odcs_v310_full_persistence migration added the correct tables and import logic for several ODCS v3.1.0 fields, but _build_contract_api_model was not updated. Fields stored on upload were silently absent from the read/export response, breaking round-trip fidelity.

Changes

All changes are export-only — no new migrations required.

data_contracts_manager.py_build_contract_api_model

Section Fix
SLA Replace flat {property: value} dict with proper List[SLAProperty], including description, scheduler, schedule, valueExt, unit, element, driver; add slaDefaultElement and contractCreatedTs to response
Team members Export name and description (added by d1 migration, present in model, not exported)
Team metadata Batch-load DataContractTeamMetadataDb and return as teamMetadata
Schema objects Export stableId, dataGranularityDescription; batch-load authoritativeDefinitions, customProperties, relationships
Schema properties Export stableId; batch-load authoritativeDefinitions, relationships

Batch queries follow the existing single-query-per-table pattern (group by parent id) to avoid N+1 issues.

data_contracts_api.pyDataContractRead

  • Add teamMetadata: Optional[TeamMetadataRead] = None field (backwards-compatible; existing responses are unchanged, new field defaults to null)

Backwards compatibility

All new fields are optional/nullable. Existing clients that do not read teamMetadata, slaProperties, or the new schema sub-fields are unaffected. The only behavioural change is that slaProperties now returns a structured list instead of an empty dict — clients already reading this field via the ODCS spec will benefit.

ODCS v3.1.0 reference

https://github.com/bitol-io/open-data-contract-standard/blob/main/schema/odcs-json-schema-v3.1.0.json

…i_model

Fixes databrickslabs#295

Several fields were stored on import but silently dropped on read/export.
All changes are export-only; no schema migrations required.

- slaProperties: replace flat {property: value} dict with proper
  List[SLAProperty] including description, scheduler, schedule, valueExt,
  unit, element, driver (fixes round-trip for all SLA fields)
- slaDefaultElement, contractCreatedTs: add to DataContractRead return
- Team members: export name and description (added in d1 migration)
- Team metadata: query DataContractTeamMetadataDb and expose as
  teamMetadata on DataContractRead (adds field to model)
- Schema objects: export stableId, dataGranularityDescription;
  batch-load and export authoritativeDefinitions, customProperties,
  relationships from three separate tables
- Schema properties: export stableId; batch-load and export
  authoritativeDefinitions, relationships from two separate tables

All batch queries follow the existing pattern (one query per table,
group by parent id) to avoid N+1 issues.
@ashmeet-kandhari ashmeet-kandhari requested a review from a team as a code owner April 27, 2026 11:51
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.

bug(contracts): ODCS v3.1.0 fields stored on import but silently dropped on export

2 participants