You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the of migration from v4 to v5 of frictionless-py in validata.fr, we experienced an unexpected KeyError when validating a tabular data which not contains a primary_key header contained in the schema used for validate data.
Traceback (most recent call last):
File "code.py", line 4, in <module>
report = frictionless.validate(
...
File "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 a'
Expected behaviour
According to the documentation of PrimaryKey specification of TableSchema, the fields related to the primary-key in the data cannot be null.
I was expected an invalid report specifying a missing-primary-key for example, mentioning the error description "Based on the schema there should be a label 'a' corresponding to the schema's primary key that is missing in the data's header." for example. (Such as for missing-label validation error.)
The expected report validation would be:
{'valid': False,
'stats': {'tasks': 1, 'errors': 1, 'warnings': 0, 'seconds': 0.003},
'warnings': [],
'errors': [],
'tasks': [{'name': 'memory',
'type': 'table',
'valid': False,
'place': '<memory>',
'labels': ['b'],
'stats': {'errors': 1,
'warnings': 0,
'seconds': 0.003,
'fields': 2,
'rows': 1},
'warnings': [],
'errors': [{'type': 'missing-primary-key',
'title': 'Missing Primary Key',
'description': 'Based on the schema there should be a '
"label 'a' corresponding to the schema's primary key"
'that is missing in the data's header.',
'message': "There is a missing primary key in the header's "
'field "a" at position "2"',
'tags': ['#table', '#header', '#label'],
'note': '',
'labels': ['b'],
'rowNumbers': [1],
'label': '',
'fieldName': 'a',
'fieldNumber': 2}]}]}
Other details and experimentations
Frictionless version 5.16.0
Same result with command line validation.
I have put "schema-sync" to reproduce more closely our use case, but it does not seem to be related with the actual issue.
The text was updated successfully, but these errors were encountered:
pierrecamilleri
changed the title
Unexpected KeyError raised related to missing 'primary_key' field schema in the tabular data columns
KeyError when a 'primary_key' is missing
Aug 30, 2024
pierrecamilleri
changed the title
KeyError when a 'primary_key' is missing
KeyError when a "primaryKey" is missing
Aug 30, 2024
- fix: deprecated dependencies ([PR
1674](#1674))
- fix: unexpected "missing-label" error with option `header_case =
False`
([#1635](#1635))
- fix: KeyError when a "primaryKey" is missing
([#1633](#1633))
- fix: unexpected field-error for a boolean "example" with "trueValues"
or
"falseValues" properties
([#1610](#1610))
Overview
In the of migration from v4 to v5 of
frictionless-py
in validata.fr, we experienced an unexpectedKeyError
when validating a tabular data which not contains aprimary_key
header contained in the schema used for validate data.For example :
Using python, it raises a KeyError:
Output:
Expected behaviour
According to the documentation of
PrimaryKey
specification ofTableSchema
, the fields related to theprimary-key
in the data cannot benull
.I was expected an invalid report specifying a
missing-primary-key
for example, mentioning the error description "Based on the schema there should be a label 'a' corresponding to the schema's primary key that is missing in the data's header." for example. (Such as formissing-label
validation error.)The expected report validation would be:
Other details and experimentations
Frictionless version 5.16.0
Same result with command line validation.
I have put "schema-sync" to reproduce more closely our use case, but it does not seem to be related with the actual issue.
The text was updated successfully, but these errors were encountered: