Does ordering result works in TG 3.0?

@xinyu

I have this very simple query in which i’m trying to order the results by outdegree.

CREATE QUERY highestdegree(/* Parameters here */) FOR GRAPH PPI { 
    SumAccum<INT>   @degree;
  
  source = {Protein.*};
  
  prots = select p from source:p 
          where p.name IN  ("APOA1", "APOA4", "APOC3", "C7", "FGFR4", "LGALS3BP", "LGALS4", "MFAP4", "P4HA1", "TAGLN", "TPM2", "TPM4")
            Accum p.@degree = p.outdegree()
          ORDER BY p.@degree DESC;

  
  PRINT prots ; 
}

Unfortunately the json result is not ordered at all.

I get the following:

[
  {
    "prots": [
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037933774",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037933774",
          "name": "TPM4",
          "dateCreated": "2018-11-22T17:27:48.561",
          "dateModified": "2018-11-22T17:27:48.561",
          "Urn": "urn:agi-llid:7171",
          "@degree": 78
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037929771",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037929771",
          "name": "FGFR4",
          "dateCreated": "2018-11-22T17:20:22.832",
          "dateModified": "2018-11-22T17:20:22.833",
          "Urn": "urn:agi-llid:2264",
          "@degree": 37
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037933492",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037933492",
          "name": "TAGLN",
          "dateCreated": "2018-11-22T17:27:06.153",
          "dateModified": "2018-11-22T17:27:06.154",
          "Urn": "urn:agi-llid:6876",
          "@degree": 59
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931968",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931968",
          "name": "P4HA1",
          "dateCreated": "2018-11-22T17:23:29.722",
          "dateModified": "2018-11-22T17:23:29.723",
          "Urn": "urn:agi-llid:5033",
          "@degree": 34
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928219",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928219",
          "name": "APOA4",
          "dateCreated": "2018-11-22T17:19:15.5",
          "dateModified": "2018-11-22T17:19:15.501",
          "Urn": "urn:agi-llid:337",
          "@degree": 9
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931383",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931383",
          "name": "MFAP4",
          "dateCreated": "2018-11-22T17:22:30.116",
          "dateModified": "2018-11-22T17:22:30.117",
          "Urn": "urn:agi-llid:4239",
          "@degree": 8
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928228",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928228",
          "name": "APOC3",
          "dateCreated": "2018-11-22T17:19:15.785",
          "dateModified": "2018-11-22T17:19:15.785",
          "Urn": "urn:agi-llid:345",
          "@degree": 14
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928218",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928218",
          "name": "APOA1",
          "dateCreated": "2018-11-22T17:19:15.49",
          "dateModified": "2018-11-22T17:19:15.49",
          "Urn": "urn:agi-llid:335",
          "@degree": 108
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931161",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931161",
          "name": "LGALS3BP",
          "dateCreated": "2018-11-22T17:22:07.127",
          "dateModified": "2018-11-22T17:22:07.128",
          "Urn": "urn:agi-llid:3959",
          "@degree": 135
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928537",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037928537",
          "name": "C7",
          "dateCreated": "2018-11-22T17:19:24.151",
          "dateModified": "2018-11-22T17:19:24.152",
          "Urn": "urn:agi-llid:730",
          "@degree": 5
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931181",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037931181",
          "name": "LGALS4",
          "dateCreated": "2018-11-22T17:22:08.4",
          "dateModified": "2018-11-22T17:22:08.4",
          "Urn": "urn:agi-llid:3960",
          "@degree": 12
        }
      },
      {
        "v_id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037933771",
        "v_type": "Protein",
        "attributes": {
          "id": "https://data.elsevier.com/lifescience/entity/resnet/protein/72057594037933771",
          "name": "TPM2",
          "dateCreated": "2018-11-22T17:27:48.536",
          "dateModified": "2018-11-22T17:27:48.536",
          "Urn": "urn:agi-llid:260",
          "@degree": 83
        }
      }
    ]
  }
]

I need the functionality for later to find topk values by adding a limit as can be found throughout the doc.

Is there something that i am missing, or is it a bug in TG 3.0 ?

PS:

*Please ignore the way i am obtaining the vertex id here. No idea how to do the equivalent of *
to_vertex(STRING id, STRING vertex_type), i.e. to_vertex_set(SET<STRING>, STRING vertex_type), because i have no idea how to declare SET<STRING> within the query. Studio does not allow me to create a list or set of strings, although as a parameter the declaration is ok. If in the process someone include the way to declare a fixed list/set of strings to be converted in vertex with to_vertex_set, that would help.

Alright found out the issue: order by does not work in interpreted mode.

https://docs.tigergraph.com/dev/gsql-ref/querying/appendix-query/interpreted-gsql-limitations#gsql-features-not-yet-supported-in-interpreted-mode

Nonthesles as a side question:

How to declare a list of string and then convert them into a vertexset, in order to avoid the expensive

source = {Protein.*};
  
  prots = select p from source:p 
          where p.name IN  ("APOA1", "APOA4", "APOC3", "C7", "FGFR4", "LGALS3BP", "LGALS4", "MFAP4", "P4HA1", "TAGLN", "TPM2", "TPM4")

Looking for something akin to
SET<String> as is admitted as parameter type of a query. However studio does not let me declare it as variable inside the query.

Use a global SetAccum , it will work the same.

1 Like