influxdata / influxdata/influxdb

Stored timestamps in `_value` interpreted as strings in Flux query

Open
#14,575 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug team/query
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

When applying a conversion from time to int or uint in e2e tests we get the following error:

```
--- FAIL: TestFluxEndToEnd/to_int.flux (0.23s)
end_to_end_test.go:170: failed to read meta data: failed to evaluate map function: strconv.ParseInt: parsing "1970-01-01T00:00:00.000000000Z": invalid syntax

--- FAIL: TestFluxEndToEnd/to_uint.flux (0.22s)
end_to_end_test.go:162: failed to evaluate map function: strconv.ParseUint: parsing "1970-01-01T00:00:00.000000000Z": invalid syntax
```

The table that causes the error is this one:

```
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string
#group,false,false,false,false,true,true
#default,_result,,,,,
,result,table,_time,_value,_field,_measurement
,,4,2018-05-22T19:53:40Z,1970-01-01T00:00:00Z,k4,m
,,4,2018-05-22T19:53:41Z,2018-05-22T19:53:26.033Z,k4,m
,,4,2018-05-22T19:53:42Z,2018-05-22T19:53:26.033066Z,k4,m
,,4,2018-05-22T19:53:43Z,2018-05-22T19:00:00+01:00,k4,m
```

The error happens here https://github.com/influxdata/flux/blob/52bf9ec1b0e1b0be208f111b10d2d4638ea8d23c/stdlib/universe/typeconv.go#L183 (for ints).

It seems that the value gets erroneously interpreted as a string instead of a timestamp.

The problem doesn't happen in Flux, so I suspect that this has something to do with the fact that, in InfluxDB, we store data using a `to` transformation before querying. Maybe `to` has some problems in storing `_value` as a `dateTime:RFC3339`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with stdlib/universe/typeconv.go at the referenced conversion and trace how stored _value timestamps reach the Flux type conversion. Reproduce with end_to_end_test.go using to_int.flux and to_uint.flux; done means the timestamp-valued table no longer produces string-parsing errors during those conversions.

Written by the indexing model from the issue text.

Assessment

Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.