How to returns a ListAccum<tuple>

9 views
Skip to first unread message

术士

unread,
Mar 29, 2020, 5:55:38 AM3/29/20
to gsql-users
shema

CREATE VERTEX MACHINE (PRIMARY_ID ip STRING, ip STRING)
CREATE VERTEX SERVICE (PRIMARY_ID name STRING, name STRING)

CREATE DIRECTED EDGE TRAFFIC (FROM MACHINE, TO MACHINE, traffic_date STRING, app_proto STRING)
CREATE DIRECTED EDGE TRAFFIC_TYPE (FROM MACHINE, TO SERVICE, traffic_date STRING)

CREATE GRAPH traffic (MACHINE,SERVICE,TRAFFIC,TRAFFIC_TYPE)

query

CREATE QUERY GetAppProto(STRING traffic_date,UINT min_src) FOR GRAPH traffic returns (ListAccum<RESULT_TYPE>){
        TYPEDEF tuple
<STRING ip,STRING date,STRING app_proto> RESULT_TYPE;
       
ListAccum<RESULT_TYPE> @@RESULTS;
       
GroupByAccum<STRING ip,STRING date,STRING app_proto ,SumAccum<INT>num > @@DstAccum;
       
#STRING d = datetime_format(now(),"%Y-%m-%d%");
        machine
= {MACHINE.*};
        results
= SELECT p
                  FROM machine
-(
TRAFFIC:l)->:p
                  WHERE l
.traffic_date == traffic_date
                  ACCUM
                   
@@DstAccum += (p.ip,l.traffic_date,l.app_proto->
1);
       
  FOREACH d IN
@@DstAccum DO
          IF d
.num >= min_src THEN
           
@@RESULTS += RESULT_TYPE(d.ip,d.date,d.app_proto);
         
END;
       
END;
 

        PRINT
@@RESULTS;
        RETURN
@@RESULTS;
}


image



I'm nor sure it's suitable to use it  or how to fix it .

Xinyu Chang

unread,
Mar 30, 2020, 12:34:36 PM3/30/20
to 术士, gsql-users
In order to return a list of tuple, please define your tuple from your schema instead of inside the query.

Thanks.


Xinyu Chang
Director of Customer Solutions
TigerGraph, Inc.


--
Welcome to GSQL-user group.
- our mission is bringing the power of graph databases to everyone www.opengsql.org
- technical resource can be found here https://docs.tigergraph.com/
---
You received this message because you are subscribed to the Google Groups "gsql-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gsql-users+...@opengsql.org.
To view this discussion on the web visit https://groups.google.com/a/opengsql.org/d/msgid/gsql-users/bf2095f8-db4d-4760-a507-7a1f80aa5ed1%40opengsql.org.
Reply all
Reply to author
Forward
0 new messages