Skip to content

Validation fails with schema-sync for a required and unique field if column is missing from data #1739

Open
@pierrecamilleri

Description

@pierrecamilleri

Under the following conditions :

  • A field has the "required" constraint
  • A field has the "unique" constraint
  • The column is missing from the data
  • Data is validated with the --schema-sync option

The validation raises the following Exception :

...
line 325, in row_stream
    cell = row[field_name]
  File "/home/pierre/Documents/multi/opendatafrance/validata/validata-table/.venv/lib/python3.10/site-packages/frictionless/table/row.py", line 73, in __missing__
    return self.__process(key)
  File "/home/pierre/Documents/multi/opendatafrance/validata/validata-table/.venv/lib/python3.10/site-packages/frictionless/table/row.py", line 281, in __process
    raise KeyError(f"Row does not have a field {key}")
KeyError: 'Row does not have a field <name of field>'

No exception occurs if any of these conditions is removed.

Steps to reproduce

schema.json :

{
    "fields": [
        {
            "name": "myField",
            "constraints": {
                "required": true,
                "unique": true
            }
       }
    ]
}

data.csv :

A,B
1,2

Command :

frictionless validate --schema schema.json data.csv --schema-sync

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions