Skip to content

Surprising Behaviour (test checks and import) #1278

Closed

Description

@rob-h-w

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.yaml

Gives:

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

  1. changed the title [-]Write About Import Behaviour on Unsupported Field Import - Implications for Export?[/-] [+]Surprising Behaviour (test checks and import)[/+] on Jun 10, 2026
  2. jschoedl commented on Jun 12, 2026

    @jschoedl
    Collaborator

    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 dropped
    • datacontract import jsonschema: warn when a union type got collapsed to a string

    Did I miss something?

  3. added
    enhancement
    on Jun 12, 2026
  4. rob-h-w commented on Jun 15, 2026

    @rob-h-w
    ContributorAuthor

    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.

  5. rob-h-w commented on Jun 16, 2026

    @rob-h-w
    ContributorAuthor

    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 test operation requires Databricks write permissions because it attempts to CREATE VIEW, and there's no way to persuade it not to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions