orientechnologies / orientdb

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
https://orientdb.dev
Apache License 2.0
4.74k stars 870 forks source link

Inline sorting of traversal result in SELECT projection #9564

Open MarttiR opened 3 years ago

MarttiR commented 3 years ago

OrientDB Version: 3.1.8 (docker)

I don't think this exists yet, so this is probably a feature request.

It would be great to have a way to sort the partial result set returned by a traverse function (e.g. out()). This would make it a lot easier to control the order of nested traversal projections.

Example

SELECT
  /* as method, string argument -> single sort */
  out("hasContainer").sort("id:asc"):{
    id,
    size,
    /* as method, array argument -> multiple sort */
    out("hasContent").sort(["promisedDeliveryDate:desc", "id:asc"]):{
      id,
      dispatchDate,
      promisedDeliveryDate,
      /* Maybe as a function? I think it is a less readable syntax. */
      sort(out("hasLineItems"), "lineId:asc"):{
        lineId,
        name,
        quantity
      } AS lineItems
    } AS contents
  } AS containers
FROM Manifest;
MarttiR commented 3 years ago

Duplicates #6715.