怎样 返回 ListAccum<tuple>

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;
}

我不太清楚是不是用得不对,还是说不能这样写

您这个情况得先定义一个全局的Tuple,而不是针对单个query的Tuple。
比如在Gsql中建议一个全局的tuple:

GSQL > TYPEDEF tuple<name string, age int> RESULT_TYPE

然后再在图traffic中建立一个query:

CREATE QUERY test(/* Parameters here */) FOR GRAPH traffic returns (ListAccum<RESULT_TYPE>){ 
  ListAccum<RESULT_TYPE> @@result;
	@@result += RESULT_TYPE("Tom", 13);
	return @@result;
}

即可成功运行。
更多请参考官网的说明https://docs.tigergraph.com/dev/gsql-ref/querying/output-statements-and-file-objects#return-statement