links-lang / links

Links: Linking Theory to Practice for the Web
http://www.links-lang.org
Other
333 stars 43 forks source link

orderby in the context of temporal tables #1125

Open vcgalpin opened 2 years ago

vcgalpin commented 2 years ago

Using the valid-time database from tests/shredding/validtime.links, the following error occurs when using the temporal data projection function to select a field for sorting:

links> query nested { for (x <-v- employees) orderby (vtData(x).salary) [vtData
***: Error: "Assert_failure core/query/query.ml:446:12" 

This also happens with either of the time projection functions:

links> query nested { for (x <-v- employees) orderby (vtFrom(x)) [vtData(x)] };
***: Error: "Assert_failure core/query/query.ml:446:12" 
jamescheney commented 2 years ago

This isn't tremendously surprising, since orderby is supported only by the flat query policy.

Since temporal queries are using "query nested" only to benefit from record flattening (i.e. nested records) at the moment, a shorter-term workaround would be to augment flat queries with support for record flattening too (this transformation is straightforward and ought to be easy to adapt to deduplication queries too).

SimonJF commented 2 years ago

I'm not sure what the semantics would be given the temporal data dimension. I think that really we should only allow orderby on timeslices of temporal tables, i.e.,

query nested { for (x <- vtCurrent(employees)) orderby (x.salary) [x] };

Regardless, this should be caught by a type error rather than a runtime error.