We have updated our database from 2.0.0rc to 2.0.2. In 2.0.2 the last()-function does not work as expected. In 2.0.0rc it returns the final record. In 2.0.2 it does not! I have used below script in both 2.0.0rc and 2.0.2 and they provide me with different results.
I have created a file to replicate the issue - unfortunately, as a new user I am not allowed to upload it to this post. The file contains >8000 lines similar to lines below. The timestamp is in milliseconds.
Adding the group()-function does fix my issue!!! So thank you.
However, I still consider the behavior as faulty, because the last()-function works different in 2.0.0 and 2.0.2. I would also like to clarify that in 2.0.2, the last()-function only returns one sample… Secondly, all records are in the same table (table 0) so - to my understanding - the group()-function should not be necessary.
I just encountered this issue. I’m retrieving metric values in timestamp order, and last() worked correctly for a few days (returning a single most recent value), then stopped working (returning a single older value). There were no configuration changes made to the database or to the query during the time between when it was working and when it stopped working.
Adding a group() statement to the query has restored the expected behaviour.
I can reproduce this oddness with my dataset in the data explorer, and have observed the following:
a) first() always works, with and without a group() - returns _time 2020-12-13T22:37:33.494Z
b) last() without the group() returns _time 2020-12-13T23:59:55.833Z
c) last() with the group() returns _time 2020-12-16T09:10:57.566Z
There are over a thousand records between 2020-12-13T22:37:33.494Z and 2020-12-13T23:59:55.833Z, and tens of thousands of records after that timestamp. Nothing unusual at that time, too. A full query shows results before, at, and after that time.