Skip to content

Support composite constraints in KG builder schemas#512

Open
adamnsch wants to merge 2 commits intoneo4j:mainfrom
adamnsch:adamnsch/composite-constraints
Open

Support composite constraints in KG builder schemas#512
adamnsch wants to merge 2 commits intoneo4j:mainfrom
adamnsch:adamnsch/composite-constraints

Conversation

@adamnsch
Copy link
Copy Markdown
Contributor

@adamnsch adamnsch commented Apr 16, 2026

Description

Summary

  • Add composite (multi-property) constraint support for UNIQUENESS and KEY
    constraint types
  • ConstraintType gains a property_names: Tuple[str, ...] field; the old
    property_name: str field is deprecated but still accepted via a
    before-validator migration
  • EXISTENCE constraints are validated to exactly one property (Neo4j
    doesn't support composite existence)
  • Parquet metadata now includes a structured constraints list alongside
    per-column is_primary_key/is_unique booleans, preserving composite
    grouping for downstream consumers
  • LLM extraction prompt updated to use property_names (list) format only
  • All existing tests migrated from property_name to property_names;
    backward-compat test explicitly asserts the deprecation warning

Breaking changes

None. The old property_name field is still accepted in input (dicts,
JSON) and migrated automatically. Accessing constraint.property_name on
an instance emits a DeprecationWarning.

Testing

14 new unit tests cover: composite KEY/UNIQUENESS creation and validation,
EXISTENCE rejection of composite, backward-compat migration, property
validation, exclusivity checks, ParquetWriter metadata output with
composite constraints, LLM extraction round-trip for composite
KEY/UNIQUENESS, and extraction filtering (rejects composite EXISTENCE,
drops composites referencing nonexistent properties). Existing tests
updated to use property_names throughout.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update
  • Project configuration change

Complexity

Complexity: Medium

How Has This Been Tested?

  • Unit tests
  • E2E tests
  • Manual tests

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • Unit tests have been updated
  • E2E tests have been updated
  • Examples have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed
  • CHANGELOG.md updated if appropriate

@adamnsch adamnsch force-pushed the adamnsch/composite-constraints branch from 28c815e to 2e064b9 Compare April 16, 2026 12:14
@adamnsch adamnsch force-pushed the adamnsch/composite-constraints branch from 2e064b9 to 738b366 Compare April 16, 2026 12:44
@adamnsch adamnsch changed the title WIP: Support composite constraints in KG builder schemas Support composite constraints in KG builder schemas Apr 17, 2026
@adamnsch adamnsch marked this pull request as ready for review April 17, 2026 09:15
@adamnsch adamnsch requested a review from a team as a code owner April 17, 2026 09:15
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.

1 participant