feat: add validation layers for generated datasets#16
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
This pull request introduces a comprehensive validation framework for generated datasets, ensuring that all schema constraints are enforced after data generation. The new
validatorpackage checks for NOT NULL, PRIMARY KEY, UNIQUE, and FOREIGN KEY violations, and aggregates all errors into a structured validation result. The main changes are grouped as follows:Core validation logic and architecture:
validatorpackage, including the mainValidatefunction, which checks all schema constraints for a generated dataset and returns aValidationResultlisting every violation. This includes helper types and functions for error reporting and primary key indexing.Constraint-specific validation checks:
checkNotNullto ensure all NOT NULL columns have non-nil values in every row.checkPrimaryKeyto verify that primary key columns are non-nil and that primary key values are unique across all rows.checkUniqueto enforce uniqueness constraints on specified column sets, reporting any duplicate value combinations.checkForeignKeysto ensure that all foreign key values reference existing primary key values in the referenced table, handling both single-column and composite keys.## What does this PR do?Why is it needed?
Closes #
How was it tested?
Does it change any existing behavior?
Checklist
make testpasses (go test ./... -race)make lintpasses (golangci-lint run ./...)time.Now()or unseeded randomness in the generation pipelinemake test-golden UPDATE=true)