finos / datahelix

The DataHelix generator allows you to quickly create data, based on a JSON profile that defines fields and the relationships between them, for the purpose of testing and validation
https://finos.github.io/datahelix/
Apache License 2.0
141 stars 50 forks source link

Unique field constraint is ignored using inMap #1711

Open semisft opened 3 years ago

semisft commented 3 years ago

Bug report

Description of the bug

Using unique field constraint is ignored using inMap.

Steps to reproduce:

Using the profile

{
    "fields": [
        {
            "name": "number",
            "type": "integer",
            "nullable": false,
            "unique": true
        }
    ],
    "constraints": [
        {
            "field": "number",
            "inMap": "numbers.csv",
            "key": "number"
        }
    ]
}

with the csv file numbers.csv

number,name
1,A
2,B
3,C
4,D
5,E
6,F
7,G
8,H
9,I
10,J

Run datahelix in random mode. Here are the command line arguments I used to run the profile:

generate
--max-rows=10
--replace
--profile-file=D:\path\to\helix\profile.json
--output-path=D:\path\to\helix\out.csv
--output-format=csv
--generation-type=RANDOM
--set-from-file-directory=D:\path\to\helix

Expected result:

Unique rows are generated from 1 to 10.

Actual result:

Duplicate values are generated.

number
1
5
5
2
1
7
4
7
3
2