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
The library supports foreign keys described in the Table Schema specification. It means if your data package descriptor use resources[].schema.foreignKeys property for some resources a data integrity will be checked on reading operations.
const{Package}=require('datapackage')constpackage=awaitPackage.load(DESCRIPTOR)teams=package.getResource('teams')awaitteams.checkRelations()// tableschema.exceptions.RelationError: Foreign key "['city']" violation in row "4"
As we could see there is a foreign key violation. That's because our lookup table cities doesn't have a city of Munich but we have a team from there. We need to fix it in cities resource:
Fixed! But not only a check operation is available. We could use relations argument for resource.iter/read methods to dereference a resource relations:
Instead of plain city name we've got a dictionary containing a city data. These resource.iter/read methods will fail with the same as resource.check_relations error if there is an integrity issue. But only if relations: true flag is passed.
The text was updated successfully, but these errors were encountered:
It's just a mirror of frictionlessdata/datapackage-py#155
Proposed API
The library supports foreign keys described in the Table Schema specification. It means if your data package descriptor use
resources[].schema.foreignKeys
property for some resources a data integrity will be checked on reading operations.Consider we have a data package:
Let's check relations for a
teams
resource:As we could see there is a foreign key violation. That's because our lookup table
cities
doesn't have a city ofMunich
but we have a team from there. We need to fix it incities
resource:Fixed! But not only a check operation is available. We could use
relations
argument forresource.iter/read
methods to dereference a resource relations:Instead of plain city name we've got a dictionary containing a city data. These
resource.iter/read
methods will fail with the same asresource.check_relations
error if there is an integrity issue. But only ifrelations: true
flag is passed.The text was updated successfully, but these errors were encountered: