-
Notifications
You must be signed in to change notification settings - Fork 17
03 Loading Entities
hkuich edited this page Nov 22, 2021
·
1 revision
person sub entity,
owns first-name,
...
owns phone-number,
...
owns nick-name,
plays ...;
first_name,last_name,phone_number,city,age,nick_name
Melli,Winchcum,+7 171 898 0853,London,55,
Celinda,Bonick,+370 351 224 5176,London,52,
Chryste,Lilywhite,+81 308 988 7153,London,66,
...
{
"globalConfig": {...},
"attributes": {...},
"entities": { // all entities go here
"person": { // key for generator in entities, must be unique
"data": [ // files from which to load data
"src/test/resources/1.0.0/phoneCalls/person.csv",
"src/test/resources/1.0.0/phoneCalls/person_nextfile.csv"
],
"insert": {
"entity": "person", // entity type to insert
"ownerships": [ // attributes the entity owns
{
"attribute": "first-name", // attribute type to insert
"column": "first_name" // column from which to load values
},
...,
{
"attribute": "phone-number",
"column": "phone_number",
"required": true // required defaults to false - if set to true, TypeDB Loader only inserts a data row if a value in this column exists and is of the correct type/can be cast
},
...,
{
"attribute": "nick-name",
"column": "nick_name",
"listSeparator": ";" // if column in a data file is a list of values, TypeDB Loader will split the list with the provided listSeparator and insert len(list) number of attributes
}
]
}
},
...
}
TypeDB Loader will ensure that the entity you are trying to insert is present in your schema. It will also ensure that all values in your data files adhere to the attribute's value type specified in your schema or try to cast them. If a value cannot be cast, it is not inserted, and the line written out into an error log see logging.
See the full phone-calls schema here.
See the full phone-calls config file here.
See the full data file here.