Build-in-functions

Looking at the file “…dev/gdk/src/document/examples/tutorial/social/social_query.gsql” I see an interesting comment:

B.neighbors() is a built-in function

Where B is declared as: SocialUser:B

Question: I’m guessing SocialUser is part of this demo and not part of the GSQL API. Please clarify and tell me where its created so I can know more about it such as its code and how to use it.

Thank you and below is the query where it was used.

##################

7.4 social_query4.gsql

##################

CREATE QUERY socialOneWay(int mutual_contacts_min = 5, int mutual_contacts_max = 10)

FOR GRAPH gsql_demo

{

    typedef tuple<vertex<SocialUser> id, string name, int cnt> recTuple;

    # SumAccum<list<recTuple>> @recList; # v0.1 to v0.1.2

    ListAccum<recTuple> @recList; # v0.2

 

    Start = {SocialUser.*};

 

    Result = SELECT B

        FROM Start:A-(SocialConn)->SocialUser:B

          #  B.neighbors() is a built-in function which returns the list of neighbors which B points to.

          #  B.neighbors('edgeType1') returns only the neighbors connected by the given edge type.

        WHERE B NOT IN A.neighbors("reverse_conn") AND

            COUNT(A.neighbors("SocialConn") INTERSECT B.neighbors("SocialConn")) >= mutual_contacts_min AND

            COUNT(A.neighbors("SocialConn") INTERSECT B.neighbors("SocialConn")) <= mutual_contacts_max

        ACCUM  B.@recList += recTuple(A, A.name, COUNT(A.neighbors("SocialConn") INTERSECT B.neighbors("SocialConn")));

    PRINT Result; # the result includes B's static attributes and B.@fromName.

}

Hi George,

Here’s the location of both the social graph and the documentation for the vertex function neighbors() - not sure which you were talking about.

The social graph is located in this directory : ~/tigergraph/document/examples/tutorial/social

Documentation for vertex functions is here : https://docs.tigergraph.com/dev/gsql-ref/querying/operators-functions-and-expressions#vertex-functions

This documentation covers everything you need to know about GSQL.

Thanks,

Kevin