Hi @Khan,
It seems that you cannot load local files (i.e. files uploaded to TigerGraph host machine) when you call the loading job via the REST API.
The reason for this is that you must specify the filename=
parameter in the query. Its value must refer to filevar specified by a DEFINE FILENAME
statement in your loader job. The REST API request will run the loading job with the USING
clause, setting a new value to the referenced filevar. (I assume that this new value will be some temporary directory on the server’s local disk into which the data file has been uploaded by the REST API request). Thus the original hard-coded reference to a local file is lost/ignored.
Furthermore, according to the documentation, if a loading job is run with the USING
clause, then only those steps in the loading job will be executed whose filevar is mentioned in the USING
clause. Since you can specify only one filename=
parameter in the REST API URL, you can load only one file in a single request, and that file will be the one that you just uploaded. The rest of filevars will be ignored and so will be the matching loading steps. The documentation also says that if the USING
clause is omitted, then the entire loading job will be run, but you can’t trick the REST API into this, as you cannot omit the filename=
parameter.
So, if you have to load a number of different files, you need to call the /ddl/
request once for each. The good news is that you can have a single loading job, all you need to do is to refer to a different filevar each time.
Summary:
If your loading job is something like this:
CREATE LOADING JOB MyJob FOR GRAPH MyGraph {
DEFINE FILENAME f1;
DEFINE FILENAME f2;
DEFINE FILENAME f3;
LOAD f1
TO VERTEX v1 VALUES (...)
USING SEPARATOR = ",";
LOAD f2
TO VERTEX v2 VALUES (...)
USING SEPARATOR = ",";
LOAD f3
TO EDGE e1 VALUES (...)
USING SEPARATOR = ",";
}
then you need to call the REST API three times:
curl -X POST --data-binary @file1.csv "http://localhost:9000/ddl/MyGraph?tag=MyJob&filename=f1"
curl -X POST --data-binary @file2.csv "http://localhost:9000/ddl/MyGraph?tag=MyJob&filename=f2"
curl -X POST --data-binary @file3.csv "http://localhost:9000/ddl/MyGraph?tag=MyJob&filename=f3"
NOTE: you must prefix the filename with “@” otherwise the filename itself will be considered the data to be loaded.
Or you can have separate loading jobs for each of your files.