From 8dc61963136b0516206b60f06988886e39ac9533 Mon Sep 17 00:00:00 2001 From: Mingxi Wu Date: Wed, 11 Sep 2024 18:10:12 -0700 Subject: [PATCH] add q2.gsql --- .../docker/tutorial/4.x/script/q2.gsql | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 demos/guru_scripts/docker/tutorial/4.x/script/q2.gsql diff --git a/demos/guru_scripts/docker/tutorial/4.x/script/q2.gsql b/demos/guru_scripts/docker/tutorial/4.x/script/q2.gsql new file mode 100644 index 00000000..3ce41fcf --- /dev/null +++ b/demos/guru_scripts/docker/tutorial/4.x/script/q2.gsql @@ -0,0 +1,29 @@ +USE GRAPH financialGraph + +# create a query +CREATE OR REPLACE QUERY q2 (string accntName) SYNTAX v3 { + + // declare an local sum accumulator; you can keep adding values into it + // "local accumulator" means each vertex will have an accumulator of + // the declared type and can be accumulated into based on the + // FROM clause pattern. + SumAccum @totalTransfer = 0; + + // match an edge pattern-- symbolized by ()-[]->() + // v is a vertex set variable holding the selected vertex set + v = SELECT b + FROM (a:Account {name: accntName})-[e:transfer]->(b:Account) + //for each matched row, do the following accumulation + ACCUM b.@totalTransfer += e.amount; + + //output each v and their static attribute and runtime accumulators' state + PRINT v; + +} + +#compile and install the query as a stored procedure +install query q2 + +#run the query +run query q2("Scott") +