informatics-isi-edu / ermrestjs

ERMrest client library in JavaScript
Apache License 2.0
4 stars 3 forks source link

Change the default sort order #938

Open RFSH opened 2 years ago

RFSH commented 2 years ago

Currently, the default sort order that we're using for reading a data set comes from the row_order defined under table-display annotation. If missing, we will use the shortest key columns as the default order.

For tables with system columns, this means using @sort(RID) (ascending order of RID). In most cases, we found that this is not a good default as we're usually setting the row_order to be the descending order of RMT (the newly modified data should come first). In this issue, we want to consider ways to facilitate this.

Based on a brief conversation that we had, we could,

  1. Use the descending RMT as our default if system columns are defined instead of just using the shortest key columns.

  2. Allow definition of default sort order on catalog or schema. Since the current row_order is part of table-display, I don't think allowing this annotation on schema/catalog would make sense. So we most probably should come up with either a new annotation or add it to the existing display annotation.

P.S. While discussing this, one suggestion was changing the default sort from ascending of the shortest key to descending. This was because we assumed sorting of RID works similarly to RMT. But RID order will not behave as expected when RIDs change in length. i.e., they are lexicographically sorted as strings, not as a monotonic numeric range. Also, RCT would be the proxy for RID as a serial creation order.