Skip to content

Commit

Permalink
Create load-data.cypher
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxiw authored Jan 21, 2025
1 parent bbd5159 commit 160fc2b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions demos/guru_scripts/docker/tutorial/4.x/cypher/load-data.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
USE GRAPH financialGraph

DROP JOB load_s3_file
DROP DATA_SOURCE s3_data_source_0

#define a data source from s3
CREATE DATA_SOURCE s3_data_source_0 = "{\"access.key\":\"none\",\"secret.key\":\"none\",\"file.reader.settings.fs.s3a.aws.credentials.provider\": \"org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider\",\"type\":\"s3\"}" FOR GRAPH financialGraph


CREATE LOADING JOB load_s3_file {
// define the s3 location of the source files; each file path is assigned a filename variable.
DEFINE FILENAME account="""$s3_data_source_0:{"file.uris":"s3a://tigergraph-example-data/ecosys/account.csv"}""";
DEFINE FILENAME phone="""$s3_data_source_0:{"file.uris":"s3a://tigergraph-example-data/ecosys/phone.csv"}""";
DEFINE FILENAME city="""$s3_data_source_0:{"file.uris":"s3a://tigergraph-example-data/ecosys/city.csv"}""";
DEFINE FILENAME hasPhone="""$s3_data_source_0:{"file.uris":"s3a://tigergraph-example-data/ecosys/hasPhone.csv"}""";
DEFINE FILENAME locatedIn="""$s3_data_source_0:{"file.uris":"s3a://tigergraph-example-data/ecosys/locate.csv"}""";
DEFINE FILENAME transferdata="""$s3_data_source_0:{"file.uris":"s3a://tigergraph-example-data/ecosys/transfer.csv"}""";
//define the mapping from the source file to the target graph element type. The mapping is specified by VALUES clause.
LOAD account TO VERTEX Account VALUES ($"name", gsql_to_bool(gsql_trim($"isBlocked"))) USING header="true", separator=",";
LOAD phone TO VERTEX Phone VALUES ($"number", gsql_to_bool(gsql_trim($"isBlocked"))) USING header="true", separator=",";
LOAD city TO VERTEX City VALUES ($"name") USING header="true", separator=",";
LOAD hasPhone TO Edge hasPhone VALUES ($"accnt", gsql_trim($"phone")) USING header="true", separator=",";
LOAD locatedIn TO Edge isLocatedIn VALUES ($"accnt", gsql_trim($"city")) USING header="true", separator=",";
LOAD transferdata TO Edge transfer VALUES ($"src", $"tgt", $"date", $"amount") USING header="true", separator=",";
}

run loading job load_s3_file

0 comments on commit 160fc2b

Please sign in to comment.