It’s all abount SYNTAX V2.
I have a star-like graph with main PERSON vertex and many other vertices that add new info about person: address, phone, college, insurance, bank_account,labour account,etc
And I want to get in one QSGL query all information about person
Now I use such method:
SetAccum<STRING> @PersonsCourses;
SetAccum<STRING> @PersonsFriends;
SetAccum<STRING> @PersonsNetworkAccounts;
SetAccum<STRING> @PersonsInsurances;
SetAccum<STRING> @PersonsLabour;
GetPersonsInfo = SELECT pin
FROM person:pin - (:e) - :tgt
where pin == person_in
ACCUM CASE WHEN tgt.type == "person"
THEN pin.@PersonsFriends += tgt.name
WHEN tgt.type == "course"
THEN pin.@PersonsCourses += tgt.name
WHEN tgt.type == "network_account"
THEN pin.@PersonsNetworkAccounts += tgt.network_type
WHEN tgt.type == "insurance"
THEN pin.@PersonsInsurances += tgt.detail
WHEN tgt.type == "labour_account"
THEN pin.@PersonsLabour += tgt.position
//and so on
END;
But if I need to use more difficult logic, for example:
Get all information about person who does not have account on FACEBOOK
Even these who have no information at all(isolated vertices)
I can do it in such way
////First mark all people who have a FACEBOOK account
OrAccum @haveFacebook = false;
OrAccum @notIsolated = false;
PersonWithFacebook = SELECT p
FROM person:p - (posts_on>:e1) - network_account:s2
WHERE s2.network_type == "facebook"
ACCUM p.@haveFacebook += true;
////And then get all their information
GetPersonsInfo = SELECT pin
FROM person:pin - (:e) - :tgt
where pin.@haveFacebook == false
ACCUM CASE WHEN tgt.type == "person"
THEN pin.@PersonsFriends += tgt.name
WHEN tgt.type == "course"
THEN pin.@PersonsCourses += tgt.name
WHEN tgt.type == "network_account"
THEN pin.@PersonsNetworkAccounts += tgt.network_type
WHEN tgt.type == "insurance"
THEN pin.@PersonsInsurances += tgt.detail
WHEN tgt.type == "labour_account"
THEN pin.@PersonsLabour += tgt.position
//and so on
END;
//After that get not isolated vertices
NotIsolatedPerson = SELECT p
FROM person:p - (:e1) - :s2
ACCUM p.@notIsolated += true;
//And find those who are isolated
IsolatedPerson = SELECT p
FROM person:p
WHERE p.@notIsolated == false;
//And finally we can get result
ResultPerson = GetPersonsInfo UNION IsolatedPerson;
So I wrote 5 statements to solve this question in GSQL.In classic SQL I can easily do it in one statement using WITH and LEFT JOIN.
Maybe I miss a way to do the same in GSQL?
Is there an equivalent of WITH and LEFT JOIN clauses in GSQL?
Thank you