Sub query in while loop

I have used sub query in TG but have some trouble:

  • The sub query: test_com
  • The query: big_query
  • I expect to run multiple time the sub query in big query: after each run the size of list_trans will decrease, so I used while loop until the list_size = 0 but the while loop go infinity
> CREATE DISTRIBUTED QUERY big_query() FOR GRAPH dunt_know {
>     INT a;
>     a = test_com();
>     PRINT a;
>     WHILE (a > 0) DO
>         a = test_com(); 
>         PRINT a;
>     END;
>     PRINT "big_query works!";
> }
> CREATE QUERY test_com() FOR GRAPH dunt_know RETURNS (INT) {
>     INT num_1, num_2;
>     ListAccum<ListAccum<INT>> @@list_trans;
>     S = SELECT s FROM Customer:s -(transaction:e) - :t
>     WHERE s.wcc_id != t.wcc_id AND s.wcc_id != 0 AND t.wcc_id != 0 AND s.wcc_id > t.wcc_id
>     ACCUM @@list_trans += [s.wcc_id, t.wcc_id];
>     
>     FOREACH gd IN @@list_trans DO
>         INT a = gd.get(0);
>         INT b = gd.get(1);
>         
>         C1 = SELECT c FROM Community:c WHERE c.id == a ACCUM num_1 = c.num_com;
>         C2 = SELECT c FROM Community:c WHERE c.id == b ACCUM num_2 = c.num_com;
>         
>         IF num_1 >= num_2 THEN
>             S1 = SELECT s FROM Customer:s WHERE s.wcc_id == b POST-ACCUM s.wcc_id = a;
>         ELSE
>             S2 = SELECT s FROM Customer:s WHERE s.wcc_id == a POST-ACCUM s.wcc_id = b;
>         END;
>     END;
>     
>     PRINT "test_com works!";
>     PRINT @@list_trans.size();
>     RETURN @@list_trans.size();
> }