-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 1633 unexpected key error with primary key in schema and 1635 une…
…xpected missing label error when ignoring header case (#1641) - fixes #1633 - fixes #1635 --- This PR fixes unexpected `missing-label` error in validation report which occurs when validating tabular data in this specific case (#1635): The data contains a named column corresponding to a required field in the schema used for validation, written without respecting case-sensitivity. For example: ``` data = [["aa", "BB"], ["a", "b"]] schema = { "$schema": "https://frictionlessdata.io/schemas/table-schema.json", "fields": [ {"name": "AA", "constraints": {"required": True}}, {"name": "bb", "constraints": {"required": True}} ] } ``` It adds some test cases: - one test case to ensure that validating this tabular data with this schema and using `schema_sync=True` and `dialect=Dialect(header_case=False)` options, returns a valid report. - one test case to ensure that if validation is case-sensitive, if a name column does not respect case a missing-label occurs in validation report. - another test case to ensure that validating with missing required column "AA" with this schema and using `schema_sync=True` and `dialect=Dialect(header_case=False)` options, returns an invalid report with `missing-label` error related to field "AA". This PR also fixes unexpected KeyError raised when a primary key used in shema is missing in the tabular data to validate(#1633). For example: ``` data = [["B"], ["b"]] schema = { "$schema": "https://frictionlessdata.io/schemas/table-schema.json", "fields": [ {"name": "A"}, {"name": "B"} ], "primaryKey": ["A"] } ``` It adds some test cases: - two test cases to ensure that when a label related to the schema primary key is missing, the validation report is invalid with single missing-label error: - a test case with the schema containing the primary key field not specified as 'required' - a test case with the schema containing the primary key field specified as 'required' - a test case to deal with insensitivity case in the data label corresponding to the primary key schema field: the validation report is valid Finally, I suggest some refactoring in this PR: - refactoring removing missing required label from field info refactoring removing missing required label from field info - refactoring creating schema fields among labels part when using `schema_sync` option in `detect_schema()` `Detector` method - refactoring to introduce intermediary `TableResource` methods to create `cells` related to primary key schema. --------- Co-authored-by: Pierre Camilleri <[email protected]>
- Loading branch information
1 parent
4d334f0
commit 7861f0e
Showing
5 changed files
with
276 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.