Add support for KEY constraints to KG builder schema#511
Open
adamnsch wants to merge 6 commits intoneo4j:mainfrom
Open
Add support for KEY constraints to KG builder schema#511adamnsch wants to merge 6 commits intoneo4j:mainfrom
adamnsch wants to merge 6 commits intoneo4j:mainfrom
Conversation
NathalieCharbel
approved these changes
Apr 15, 2026
Contributor
NathalieCharbel
left a comment
There was a problem hiding this comment.
Overall looks great 🚀
A few non-blocking suggestions for improvement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary
Adds
GraphConstraintType.KEYto the experimentalGraphSchema(single property, node or relationship scope), aligned with Neo4j key constraints for mandatory presence + identity semantics. Pruning enforces presence for KEY (like EXISTENCE); uniqueness is still not validated in-process.Note: Support for composite constraints will be added in an upcoming PR.
Breaking change:
ParquetWriter/KGWriterModelmetadatametadata["files"][].columnsentries now include:is_unique—truefor UNIQUENESS-backed properties onlyis_primary_key—truefor KEY-backed properties, synthetic__id__when no KEY, and relationshipfrom/tocolumnsUNIQUENESSno longer setsis_primary_key; consumers that relied on that must useis_unique.Other changes
UNIQUENESS+KEYon the same node property is rejected at schema validation (Neo4j rule).key_property_names_for_*,uniqueness_property_names_for_node,mandatory_property_names_for_*.ExtractedConstraintTypeand extraction filter supportKEY; prompt updated.SchemaFromExistingGraphExtractor: Neo4jNODE_KEY/RELATIONSHIP_KEYmetadata maps toKEY(existence-only constraints unchanged).CHANGELOGupdated under Next.Tests
Unit tests cover schema validation, conflict case, pruning (node KEY), extraction, and Parquet column metadata (
is_primary_key/is_unique).Type of Change
Complexity
Complexity: Medium
How Has This Been Tested?
Checklist
The following requirements should have been met (depending on the changes in the branch):