influxdata / influxdata/influxdb
Points in the same series being returned in separate tables (plus duplicate points with _all_ values matching)
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__Steps to reproduce:__
More details in this [forum topic](https://community.influxdata.com/t/two-tables-returned-with-identical-group-keys/28896/5)
1. I'm using a rollup task to write data to a new bucket.
2. I wrote another flux query to put older data into the same format as this new bucket, and add that historical data to my new bucket.
3. Query the new bucket for a single series, the resultant data comes back in two tables, even though both tables have matching tags/field name for all the columns in the group key.
Query:
```
from(bucket: "power_circuit_lores")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "kw")
|> filter(fn: (r) => r["_field"] == "pair_min")
|> filter(fn: (r) => r["circuit_pair_id"] == "3303")
|> yield(name: "mean")
```
Result:

I think somehow the data must differ between the two series, even though it appears the same. During troubleshooting, I also ran into this issue:
1. Query the data that normally produces two tables.
2. Call `group` on the same group keys that were already being used. This results in all of the data in one table.
3. Call `sort` based on `_time`, which results in my graphs looking like they are supposed to.
4. Call `to` on this resultant data, in hopes that it overwrites existing data in the bucket making the query work properly from now on.
5. Now I have 2 points in the same bucket with identical data, which are still returned in separate tables:
```flux
from(bucket: "power_circuit_lores")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_field"] == "ckt_max")
|> filter(fn: (r) => r["circuit_id"] == "3304")
|> filter(fn: (r) => r["_time"] == 2023-03-01T22:00:00.000Z)
|> yield(name: "mean")
```
```csv
#group,false,false,true,true,false,false,true,true,true,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string,string,string,string
#default,mean,,,,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,account_id,circuit_id,circuit_pair_id,facility_id,panel_id
,,0,2023-02-27T15:01:59.527182778Z,2023-03-06T15:01:59.527182778Z,2023-03-01T22:00:00Z,1.248,ckt_max,kw,52,3304,3304,2,349
,,1,2023-02-27T15:01:59.527182778Z,2023-03-06T15:01:59.527182778Z,2023-03-01T22:00:00Z,1.248,ckt_max,kw,52,3304,3304,2,349
```
This also seems like a bug, as the documentation says that points with the same time and tags should overwrite the old data instead of storing a duplicate point.
__Expected behavior:__
Get a single table returned.
__Actual behavior:__
Two tables are returned, with identical data in all the group key columns.
__Environment info:__
* System info: Run `uname -srm` and copy the output here
Running in docker, this is the output from inside the container. Linux 5.4.0-131-generic x86_64
* InfluxDB version: Run `influxd version` and copy the output here
InfluxDB v2.6.1 (git: 9dcf880fe0) build_date: 2022-12-29T15:53:07Z
* Other relevant environment details: Container runtime, disk info, etc
Contributor guide
Research direction
Start by reproducing the two Flux queries against InfluxDB v2.6.1, then compare the results before and after group, sort, and to. Use the linked forum topic for additional reproduction context. Done means matching group keys produce one table and points with identical timestamps and tags do not remain duplicated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100