Problems with ORDER By

I’m having some problems using the ORDER BY clause for a SELECT statement.
I’m using a modified version of the Money Laundering starter kit that has a time tree (day, year, and month vertices). Here’s what the query looks like.

CREATE QUERY GetRecentTransactionID(INT startDate = 20160115, INT endDate = 20170115) FOR GRAPH AntiFraud{ 

  ListAccum<VERTEX> @receiverSet, @senderSet;
  SumAccum<FLoat> @receiverTrust, @senderTrust;
  Seed = {Day.*};

  s1 = SELECT t FROM Seed:d -(DAY_TO_TRANSACTION:e) -:t
       WHERE d.id < endDate AND d.id > startDate;

  s2 = SELECT t FROM s1:t -((User_Recieve_Transaction_Rev|User_Transfer_Transaction_Rev):e) - User:u
      ACCUM
          case when e.type == "User_Recieve_Transaction_Rev" then
              t.@receiverSet += u,
              t.@receiverTrust += u.trust_score
          ELSE
              t.@senderSet += u,
              t.@senderTrust += u.trust_score
          END
     ORDER BY t.ts DESC;
  
  PRINT s2;
}

The query returns the correct information I think, but there is no ordering in the JSON output.
Ex:

[
  {
    "s2": [
      {
        "v_id": "8759",
        "v_type": "Transaction",
        "attributes": {
          "ts": 1482582898,
          "amount": 63,
          "@senderTrust": 0.97658,
          "@receiverTrust": 0.45544,
          "@senderSet": [
            "3204"
          ],
          "@receiverSet": [
            "8617"
          ]
        }
      },
      {
        "v_id": "10034",
        "v_type": "Transaction",
        "attributes": {
          "ts": 1482018272,
          "amount": 79,
          "@senderTrust": 0.39547,
          "@receiverTrust": 0.13566,
          "@senderSet": [
            "6808"
          ],
          "@receiverSet": [
            "8870"
          ]
        }
      },
      {
        "v_id": "9523",
        "v_type": "Transaction",
        "attributes": {
          "ts": 1482712417,
          "amount": 58,
          "@senderTrust": 0.96144,
          "@receiverTrust": 0.21661,
          "@senderSet": [
            "119"
          ],
          "@receiverSet": [
            "9122"
          ]
        }
      },

The second result is less than the first, but the third is greater than the second.
Is there something I’m doing wrong here?

Any help would be greatly appreciated.

Thank you,
Akash Kaul

I realized the issue. The ordering only works when the query is installed, and I was running it in interpreted mode.

1 Like