Printing from a subquery

top_query Query has:

patientList = select p from population:p

             ACCUM @@topK_Heap += mysubquery(p);

The mysubquery has print statements as below

print “norms:”, normA, " ", normB;

When I run top_query, I do not see standard out of print statements in mysubquery . Is that how it is meant to be? Is there any option to turn on standard out printing from subquery and UDF’s?

Thanks

Kumar

Hi Kumar,

We cannot print from the subquery.

As a workaround, what you can do is return what you want to print to the main query, and print it there.

Thanks,

Kevin

Hi Kumar,

I would suggest using the FILE object to print to a file. You declare the location of the FILE object in the main query, and then pass the File object as a parameter to the subquery.

Then, you can print anything from the subquery to the file.

See example here

https://docs.tigergraph.com/dev/gsql-ref/querying/output-statements-and-file-objects#passing-a-file-object-as-a-parameter

To print an attrribute, you can use something similar to below

F1 = {members.*};

F1 = SELECT src FROM F0:src LIMIT 2;

PRINT F1.id, F1.@sum TO_CSV file_object;

thanks,

Mingxi