Skip to content

Fail on columns in another order than declared, when the schema says so - #1726

Open
markhm wants to merge 2 commits into
datacontract:mainfrom
markhm:feat/property-order
Open

markhm wants to merge 2 commits into
datacontract:mainfrom
markhm:feat/property-order

Conversation

@markhm

@markhm markhm commented Oct 10, 2026

Copy link
Copy Markdown

Fixes #1723.

Builds on #1725: the first commit is that PR, and this PR's own change is the last commit. Once #1725 is merged I'll rebase, and the diff shrinks to that commit.

Problem

A contract cannot say that the columns of a file must be in the declared order. Swapped columns pass unnoticed, and in a CSV file without a reliable header that hides a real error. ODCS v3.2.0 has no field for this.

What this changes

A schema opts in with a custom property:

schema:
  - name: orders
    customProperties:
      - property: propertyOrder
        value: strict
  • The schema then gets a check, "Check that the fields of orders are in the order of the contract" (type model_property_order, dimension conformity). It fails with the expected and the actual order: Fields in another order: expected order_id, quantity, amount; found order_id, amount, quantity, with expected_order and actual_order in the diagnostics.
  • It compares only the declared columns it finds. A missing column is left to the field presence check, and an extra one to additionalProperties: false from Fail on columns the contract does not declare, when the schema says so #1725. So the two settings together pin a file to exactly the declared columns, in order. They are separate because some exchanges care about the set of columns but not their order.
  • Like Fail on columns the contract does not declare, when the schema says so #1725, it reads only the column names, compares them case-insensitively, also runs with --metadata-only, and works on every server read through ibis.
  • Without the custom property nothing changes.

Tests

tests/test_test_property_order.py: 9 tests, covering the declared order, another order, a missing column, an extra column, case, no custom property, both settings together, --metadata-only, and a JSON file. uv run pytest: all pass. ruff: clean.

Docs

schema.md: a row in the checks table and a section on the setting. CHANGELOG entry under Added.

  • Tests pass (uv run pytest)
  • Code formatted (uv run ruff check --fix && uv run ruff format)
  • Docs updated (if relevant)
  • CHANGELOG.md entry added

🤖 Generated with Claude Code

markhm and others added 2 commits October 10, 2026 08:15
A schema with the custom property `additionalProperties: false` (the JSON
Schema term; ODCS has no field for it) gets a check that fails on fields of
the data the schema does not declare, and names them. It reads only the
column names, so it runs on every server read through ibis, also with
--metadata-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A schema with the custom property `propertyOrder: strict` gets a check that
the columns of the data are in the order of its properties. A missing column
is left to the presence check and an undeclared one to
`additionalProperties: false`, so the two together pin a file to exactly the
declared columns, in order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

CSV: no way to check that columns are in the declared order

1 participant