[Bug Report] lost precision for nano second _time
emeryao opened this issue · comments
This line of code converts a string to a number when the column is the _time
field
when the _time
is timestamp string of a nano second like "1698305602883000011"
the convention loses some precision to a number 1698305602883000000
Sorry for my poor English 😆
as a workaround I tried the code below and it works for me now
queryApi.collectRows(someFlux, (value, meta) => {
// precision lost
const lostPrecisionTime: any = meta.get(values,'_time');
// original nano second
const nanoSecTime: string = values[meta.column('_time').index];
});
Additional info
Originally the _time
field defaults to a string in ISO format like "2023-10-27T07:17:55Z"
in the codes below which does not contains nano seconds
queryApi.collectRows(someFlux, (value, meta) => {
console.log(values);
// output:
// [
// '',
// '10',
// '2023-10-27T07:10:30.862780217Z',
// '2023-10-27T07:30:30.862780217Z',
// '2023-10-27T07:17:55Z',
// 'field_value',
// 'field_name',
// 'measurement_name'
// ]
console.log(meta.column('_time').index);
// output: 4
});
but in my project I want to fetch the _time
field in nano second so I add a map
statement in the flux query below
from(bucket: "bucket_name")
|> range(start: -10m)
|> filter(fn: (r) => r["_measurement"] == "measurement_name")
|> map(fn: (r) => ({r with _time: uint(v: r._time)}))
with this flux query the _time
field become a nano second timestamp string like "1698305602883000011"
and the issue happens here
Sorry for the late info 😅
the overall spot is that I want to get the _time
field in nano seconds precision in the returned data
all the tricks I have done is trying to achieve that 😅
Maybe there are some other ways to fullfill my needs if so please help