Problem with the migration of attributes with the datatype of data from JSON to GRAKN


#1

Hello!
I have a problem with the migration of JSON to GRAKN, more precisely with the datatype data.

When I write a value of the datatype in quotes in JSON, I get an error:
Migrating data …/output/incidents.json using Grakn Engine localhost:4567 into graph incidents
Error in execution: ai.grakn.client.GraknClientException: Failed graqlExecute. Error status: 422, error info: The value [2018-01-01] must be of datatype [java.time.LocalDateTime]
queries: insert $x0 isa incident has uuid “896eb3c6-78a2-48ae-8b40-db7a31f34639” has worker_id “1” has severity “critical-incident” has assigned “” has incident-date “2018-01-01”.

When I remove quotes, I get an error:
Migrating data …/output/incidents.json using Grakn Engine localhost:4567 into graph incidents
ERROR: Exception while loading data (disabling debug mode might skip and continue): Expected }, but got -1 instead.
How can I migrate attributes with the datatype of data from JSON to GRAKN?
Thanks,
Varvara


#2

Hey @Varvara, try using https://dev.grakn.ai/docs/migrating-data/migration-language#macros.

More specifically:

P.s. I believe the “d” in "mm/dd/yyy"d is actually erronous. I believe it should be:

insert $x val @date(<date>, "mm/dd/yyyy");

So something like:

insert $x0 isa incident has uuid "896eb3c6-78a2-48ae-8b40-db7a31f34639" has worker_id 1 has severity "critical-incident" has assigned "" has incident-date @date("2018-01-01", "mm/dd/yyyy");

#3

Thanks for your advice, but when I substitute incident-date @date(< incident-date>, “mm/dd/yyyy”) into the migration:
I get an error:
Migrating data …/output/incidents.json using Grakn Engine localhost:4567 into graph incidents9
Query not sent to server: Cannot parse date value 2018-01-01 with format mm/dd/yyyy
Loaded 0 statements
Migration complete.
Migration is:
insert
for() do {
$x isa incident
has uuid
has worker_id <worker_id>
has severity
has assigned
has incident-date @date(< incident-date>, “mm/dd/yyyy”);
}
JSON is:
{
“incidents”: [
{
“uuid”: “896eb3c6-78a2-48ae-8b40-db7a31f34639”,
“worker”: “Никифоров Иван Васильевич”,
“worker_id”: “1”,
“severity”: “critical-incident”,
“events”: [
{
“uuid”: “01”,
“name”: “Падение”,
“event-date”: “2018-01-01”
},
{
“uuid”: “02”,
“name”: “Удар”,
“event-date”: “2018-01-01”
},
{
“uuid”: “03”,
“name”: “Неподвижность”,
“event-date”: “2018-01-01”
}
],
“assigned”: “”,
“incident-date”: “2018-01-01”
},…


#4

Apologies, didn’t look at the date format you’re using. Try using format: yyyy-mm-dd


#5

Query not sent to server: Cannot parse date value 2018-01-01 with format yyyy-mm-dd


#6

Should have probably ran some code before answering :P.

I present to you, my final (tested and working) answer:

insert $x isa file has test_date @date("2018-01-01", "yyyy-MM-dd");

#7

It works! Thank you so much!