Debug printing vertices "content"

In order to debug a query that I’m writing, I’d like to be able to display the content of the vertices that have been traversed.
I’m using something like this:

CREATE QUERY test(Vertex Src) FOR GRAPH fraud_detection_network { 
	
	BOOL debug = TRUE;
 
	start = {Src};
	WHILE start.size() > 0 limit 10 DO 
	  start = SELECT v 
	    FROM start: s - (:e) -> :v
	    ACCUM
	      // some logic...
	    POST-ACCUM
	      LOG(debug,v);
	END;
}

The problem is that it only prints the ID of the vertex, which is expected, if the behavior of LOG is the same as the behavior of PRINT - https://docs.tigergraph.com/dev/gsql-ref/querying/output-statements-and-file-objects#json-format-values.

Is there a way to print the “whole content” (i.e. attributes and accumulators) of a vertex?

So, the way to do this I use is to create a global accumulator and add the relevant vertices to that, say:

ListAccum @@log_vertices

At the end I’ll convert that into a vertex set and then print that:

vset = {@@log_vertices};
print vset;

Thanks for the response, @Richard_Henderson!

If I’m not mistaken, your suggestion wouldn’t work inside ACCUM or POST-ACCUM clause… Right?

I’m interested in looking into what’s happening during each iteration of the WHILE loop.
That’s why I’m using the LOG command…

Any idea if that’s possible? :slight_smile:

It should work fine within ACCUM/POST-ACCUM. Unlike print, which doesn’t (unless you are printing to file).

Mmmm… I think I’m missing something… :slight_smile:

Do you mean something like this?

CREATE QUERY test(Vertex Src) FOR GRAPH fraud_detection_network { 
	BOOL debug = TRUE;
	ListAccum<Vertex> @@log_vertices;
 
	start = {Src};
	WHILE start.size() > 0 limit 10 DO 
	  start = SELECT v 
	    FROM start: s - (:e) -> :v
	    POST-ACCUM
	      @@log_vertices += v,
	      vset = {@@log_vertices},
	      LOG(debug,vset);
	END;
}

When I tried it, I’ve received the following error message:

1 Like

you can try to spell out the expressions. E.g.

ACCUM
log(true, s.id, s.@SampledEdges1, s.@randomfactorList1, s.@ModMap1, randomfactor, s.@ModMap1.get(randomfactor), sampledEdges),

1 Like

Yeah, I was trying to avoid that… :smiley:
But if there’s no way to print the whole content of the vertex - I’ll do that! Thanks!

Just to finish off. Nope. I wasn’t suggesting the log approach, if you are specifically looking to apply the logging function, then MingXi’s solution is the only way I know of.

Given your routine doesn’t return any values, I meant to use the actual print function after the select block was complete. That works fine with vset’s.

CREATE QUERY test(Vertex Src) FOR GRAPH fraud_detection_network { 
BOOL debug = TRUE;
ListAccum<Vertex> @@log_vertices;

start = {Src};
WHILE start.size() > 0 limit 10 DO 
  start = SELECT v 
    FROM start: s - (:e) -> :v
    POST-ACCUM
      @@log_vertices += v
END;

    myVset = {@@log_vertices};
    print myVset;

}

Gotcha :slight_smile:
Yeah - I was specifically looking for a way to “debug” each iteration of an algorithm, so I wanted to inspect how each iteration effects the aggregators.

Thanks a lot for your time @Richard_Henderson and @Mingxi_Wu!
I really appreciate it!

1 Like