Skip to content

Propose new syntax for constraints#42

Open
hadley wants to merge 1 commit into
mainfrom
more-constraints
Open

Propose new syntax for constraints#42
hadley wants to merge 1 commit into
mainfrom
more-constraints

Conversation

@hadley

@hadley hadley commented Jun 16, 2026

Copy link
Copy Markdown
Member

#10

@hadley hadley changed the title Propose new syntax for constaints Propose new syntax for constraints Jun 16, 2026
@hadley hadley mentioned this pull request Jun 16, 2026

@lwjohnst86 lwjohnst86 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like that assertions are built into the metadata, as that would make updating and checking the data so much easier 👍

Comment thread spec.md
Comment on lines +144 to +146
constraints:
- required
- assert: LENGTH(postcode) <= 10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. This actually solves a problem we were trying to resolve with our check-datapackage. If this is built into the spec, it would solve a lot of our problems trying to work around the current tooling. 👍 One worry we had was how to prevent some type of injection against if the assertion gets evaluated. But I guess that can be sanitized before evaluating.

Comment thread spec.md

### Assertions

An `assert` expression is a single-table, row-level boolean expression written in a small SQL-like sublanguage. It is evaluated against every row, and the constraint holds when the expression is true for all of them. Bare names refer to columns of the table.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that it is SQL-like. SQL is basically the language of data and is so widely used in e.g. data engineering. 👍

@gaborcsardi

Copy link
Copy Markdown
Member

I think it would make sense to properly formalize the grammar.

@gaborcsardi gaborcsardi added this to the July sprint milestone Jul 6, 2026
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.

3 participants