From 160fc2b3c4ef20494b7fbaeb738f1b9c0f66eb08 Mon Sep 17 00:00:00 2001 From: Mingxi Wu Date: Tue, 21 Jan 2025 12:13:58 -0800 Subject: [PATCH] Create load-data.cypher --- .../tutorial/4.x/cypher/load-data.cypher | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 demos/guru_scripts/docker/tutorial/4.x/cypher/load-data.cypher diff --git a/demos/guru_scripts/docker/tutorial/4.x/cypher/load-data.cypher b/demos/guru_scripts/docker/tutorial/4.x/cypher/load-data.cypher new file mode 100644 index 00000000..2bf31c68 --- /dev/null +++ b/demos/guru_scripts/docker/tutorial/4.x/cypher/load-data.cypher @@ -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