Repository navigation
Description
Surprising Behaviour
There are two instances where I have been surprised by the behaviour of datacontract.
1 Skipping Checks
It is surprising that checks on Databricks or user-supplied dataframes run by datacontract test do not verify implicit (i.e. required: true or explicit (quality: [ ... type: sql, query: ... ]) constraints on either the data schema or the rows/blobs themselves.
2 Removing Unsupported Structure on Import
This relates to bitol-io/open-data-contract-standard#250. The behaviour when importing heterogeneous types from a JSON schema is to silently stringify the offending field(s).
I think this is reasonable behaviour given the fact that the standard does not support heterogeneity. It would be good to know about it, and have it as an explicit general rule for handing import/export to formats with varying capabilities. I propose that this behaviour be documented to remove the surprise.
Implementation Constraints & Surprise 1
For export to sodacl, given test.yaml:
apiVersion: v3.1.0
kind: DataContract
id: test
name: test
version: 1.0.0
status: draft
schema:
- name: model
physicalType: object
logicalType: object
properties:
- not_nested:
id: not_nested
name: not_nested
physicalType: string
logicalType: string
description: A non-nested property.
- nested_thing:
id: nested_thing
name: nested_thing
physicalType: object
logicalType: object
properties:
- name: id
id: id
physicalType: string
logicalType: string
description: Unique identifier.
- name: very
id: very
physicalType: object
logicalType: object
properties:
- name: nested
id: nested
physicalType: string
logicalType: string
description: Unique identifier for the very nested thing.The command:
datacontract export sodacl test.yamlGives:
checks for model:
- schema:
fail:
when required column missing:
- not_nested
name: model__not_nested__field_is_present
- schema:
fail:
when wrong column type:
not_nested: string
name: model__not_nested__field_type
- schema:
fail:
when required column missing:
- nested_thing
name: model__nested_thing__field_is_present
- schema:
fail:
when wrong column type:
nested_thing: object
name: model__nested_thing__field_type
The commonality here is that the more nested content is silently lost in some way. This is a limitation of Soda CL itself, where the solution focuses on flat tables. There is no such limitation in the ODCS standard.
Databricks and dataframes can be made to execute more capable checks than Soda CL supports. The datacontract implementation should support nested checks with Databricks and dataframes.
Activity
[-]Write About Import Behaviour on Unsupported Field Import - Implications for Export?[/-][+]Surprising Behaviour (test checks and import)[/+]jschoedl commentedon Jun 12, 2026
Thank you for the issue. Let me summarize what changes would be needed to address this:
datacontract test: make the check builder recurse into nested fields (already happens for JSON, but not for Ibis-based checks)datacontract test: warn if nested checks are skipped (for backends where they can't be represented, like CSV)datacontract export sodacl: warn if nested properties are droppeddatacontract import jsonschema: warn when a union type got collapsed to a stringDid I miss something?
rob-h-w commentedon Jun 15, 2026
That looks good. I'm going to push a PR to do the check builder recursion in ibis, at least for Databricks & dataframes.
I wanted to share here before starting to check there wasn't a good reason to avoid nested checks that I'd missed.
rob-h-w commentedon Jun 16, 2026
Hmm, it would be really good to get ibis-project/ibis@e040215 (ibis-project/ibis#11962) into the version of Ibis used with datacontract-cli. Without it, a
testoperation requires Databricks write permissions because it attempts toCREATE VIEW, and there's no way to persuade it not to do that.feat: recursive nested field checks for Spark/dataframe and Databricks
Enable recursive checks and SQL for Databricks with read-only access (d…
feat: recursive nested field checks for Spark/dataframe and Databricks
Enable recursive checks and SQL for Databricks with read-only access (d…
feat: recursive nested field checks for Spark/dataframe and Databricks
Enable recursive checks and SQL for Databricks with read-only access (d…
1278 recursive databricks and spark checks and custom queries (#1311)
fix: nested field missing-column errors and JSON Schema boolean branc…
fix: union path format, warning listing, and folded summary line (#1278)
docs: update changelog and parquet type-check documentation (#1278)
feat: nested checks warnings, sodacl export, jsonschema union handling (