Store list of vertex types in a variable, in a GSQL query

In a GSQL query I have the following two blocks:

Start = {source_party};
Start = SELECT s
        FROM Start:s -(:e)-> (ip_address|email|session|phone|device_cookie|tin|internal_account|address|street_address):t
        ACCUM @@set_size_A += 1;

SharedNeighbours = SELECT t
                   FROM Start:s -(:e)-> (ip_address|email|session|phone|device_cookie|tin|internal_account|address|street_address):t;

I would like to know if there is a way of keeping the long list of vertex types (ip_address|email|session|phone|device_cookie|tin|internal_account|address|street_address) in a variable, so that if I have to add or remove any vertex type, I only do the change in a single place.

Does this feature exist?

For this problem, you are going to want to use a STRING Set Accumulator as such:

SetAccum<STRING> @@args;
@@args += ("ip_address","email","session","phone","device_cookie","tin","internal_account","address","street_address");

Start = {source_party};
Start = SELECT s
        FROM Start:s -(:e)-> @@args:t
        ACCUM @@set_size_A += 1;

SharedNeighbours = SELECT t
                   FROM Start:s -(:e)-> @@args:t;

Note that you have to INSTALL this query for it to work.

If you run it in INTERPRETED mode, a run-time error will be thrown related to the SetAccum assignment on the second line. This is unintended behavior that the team is currently looking into.

If INTERPRETED mode is required in your use case, you need to add the elements to the accumulator line-by-line (single element added each time).

Thanks a lot. Just tested it and works great.

@lshestakov
Can you please let me know the GSQL query for this type of use case
To know the list of movies where Tom Cruise not worked

suppose we have an edge between Actor and Movie (worked_in)

@pkr2

You can do this using the WHERE clause. You might also need to change the attribute of Actor which stores their name (to comply with your exact schema).

CREATE QUERY test() FOR GRAPH MovieRecommendation {
  start = {Movie.*};
  
  movies = SELECT s from start:s - (WORKED_IN) - Actor:t where t.Name != "Tom Cruise";
  
  print movies;
}